/**
 * POPO CRM – Web Application Styles
 * Payroll lookup & agency application
 */

:root {
  --green-wash: rgba(220, 252, 231, 0.85);
  --green-wash-light: rgba(236, 253, 245, 0.9);
  --green-soft: #dcfce7;
  --green-mid: #bbf7d0;
  --green-soft-alt: #d1fae5;
  --green-mid-alt: #a7f3d0;
  --text: #14532d;
  --text-muted: #166534;
  --radius: 16px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ========== Splash screen ========== */
.splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 80% 60% at 20% 30%, rgba(236, 253, 245, 0.9) 0%, transparent 50%),
    radial-gradient(ellipse 70% 50% at 80% 20%, rgba(220, 252, 231, 0.9) 0%, transparent 45%),
    linear-gradient(180deg, #f0fdf4 0%, #dcfce7 40%, #bbf7d0 100%);
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
.splash.splash--hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.splash-inner {
  text-align: center;
  padding: 2rem;
}
.splash-logo {
  margin-bottom: 1rem;
}
.splash-logo-img {
  max-width: 200px;
  max-height: 80px;
  width: auto;
  height: auto;
  object-fit: contain;
}
.splash-logo-fallback {
  display: none;
  font-size: 2.25rem;
  font-weight: 700;
  color: #15803d;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 8px rgba(220, 252, 231, 0.8);
}
.splash-logo-fallback--show {
  display: inline-block !important;
}
.splash-tagline {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}
.splash-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.splash-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  animation: splash-bounce 1.4s ease-in-out infinite both;
}
.splash-dot:nth-child(1) { animation-delay: 0s; }
.splash-dot:nth-child(2) { animation-delay: 0.2s; }
.splash-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes splash-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* Logo in login card & app header */
.login-logo, .app-logo {
  margin-bottom: 0.5rem;
}
.login-logo-img, .app-logo-img {
  max-width: 160px;
  max-height: 56px;
  object-fit: contain;
}
.login-logo-fallback, .app-logo-fallback {
  display: none;
  font-size: 1.5rem;
  font-weight: 700;
  color: #15803d;
  text-shadow: 0 1px 2px rgba(220, 252, 231, 0.5);
}
.login-logo-fallback--show, .app-logo-fallback--show {
  display: inline-block !important;
}
.app-header .app-logo { margin-bottom: 0; margin-right: 0.75rem; flex-shrink: 0; }
.app-header .app-logo-img { max-width: 120px; max-height: 40px; }
.app-header .app-logo-fallback { font-size: 1.15rem; }
.app-title { flex: 1; font-size: 1.35rem; margin: 0; min-width: 0; }

body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 60% at 20% 30%, rgba(236, 253, 245, 0.7) 0%, transparent 50%),
    radial-gradient(ellipse 70% 50% at 80% 20%, rgba(220, 252, 231, 0.75) 0%, transparent 45%),
    radial-gradient(ellipse 60% 70% at 50% 80%, rgba(187, 247, 208, 0.6) 0%, transparent 50%),
    radial-gradient(ellipse 90% 50% at 60% 50%, rgba(167, 243, 208, 0.5) 0%, transparent 55%),
    linear-gradient(180deg, #f0fdf4 0%, #dcfce7 30%, #bbf7d0 70%, #d1fae5 100%);
  background-attachment: fixed;
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

/* Login */
.login-wrap {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 1.5rem;
}
.login-card {
  background: linear-gradient(165deg, rgba(255,255,255,0.95) 0%, rgba(236, 253, 245, 0.4) 40%, rgba(220, 252, 231, 0.5) 100%);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(34, 197, 94, 0.15), 0 4px 16px rgba(22, 163, 74, 0.1);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  border: 1px solid rgba(34, 197, 94, 0.35);
  backdrop-filter: blur(8px);
  text-align: center;
}
.login-card--apply {
  max-width: 460px;
  margin-top: 0;
}
.login-card h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: #15803d;
  text-shadow: 0 1px 2px rgba(220, 252, 231, 0.5);
}
.login-card h2 {
  font-size: 1.15rem;
  color: #15803d;
  margin-bottom: 0.5rem;
}
.login-card .sub {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
}
.login-card .form-group { text-align: left; }

.form-group {
  margin-bottom: 1.25rem;
}
.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.4rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="month"] {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  font-family: inherit;
  border: 1px solid rgba(34, 197, 94, 0.4);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.8);
  transition: border-color 0.2s, box-shadow 0.2s;
}
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="month"]:focus {
  outline: none;
  border-color: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
}
input::placeholder { color: #059669; }

textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  font-family: inherit;
  border: 1px solid rgba(34, 197, 94, 0.4);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.8);
  min-height: 80px;
  resize: vertical;
}
textarea:focus {
  outline: none;
  border-color: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
}

select {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  font-family: inherit;
  border: 1px solid rgba(34, 197, 94, 0.4);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.8);
  cursor: pointer;
}
select:focus {
  outline: none;
  border-color: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s, transform 0.05s, box-shadow 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}
.btn-primary {
  background: linear-gradient(180deg, #dcfce7 0%, #bbf7d0 50%, #86efac 100%);
  color: #14532d;
  width: 100%;
  margin-top: 0.25rem;
  border: 1px solid rgba(34, 197, 94, 0.5);
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.2);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #bbf7d0 0%, #86efac 100%);
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}
.btn-secondary {
  background: rgba(236, 253, 245, 0.9);
  color: #166534;
  border: 1px solid rgba(34, 197, 94, 0.6);
}
.btn-secondary:hover:not(:disabled) {
  background: #d1fae5;
  border-color: #22c55e;
}
.btn-accent {
  background: linear-gradient(180deg, #d1fae5 0%, #a7f3d0 50%, #5eead4 100%);
  color: #14532d;
  border: 1px solid rgba(34, 197, 94, 0.5);
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3);
}
.btn-accent:hover:not(:disabled) {
  background: linear-gradient(180deg, #a7f3d0 0%, #5eead4 100%);
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
}

/* Messages */
.msg {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}
.msg.info { background: rgba(220, 252, 231, 0.8); color: #166534; border: 1px solid #86efac; }
.msg.error { background: rgba(254, 226, 226, 0.9); color: #b91c1c; border: 1px solid #fca5a5; }
.msg.warn { background: rgba(254, 243, 199, 0.9); color: #854d0e; border: 1px solid #fde68a; }

.hidden { display: none !important; }

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 1.25em;
  height: 1.25em;
  border: 2px solid rgba(34, 197, 94, 0.3);
  border-top-color: #22c55e;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 0.5rem;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.btn .spinner { margin-right: 0.5rem; }

/* App layout */
#appView {
  width: 100%;
  max-width: 960px;
}
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(120deg, rgba(220, 252, 231, 0.9) 0%, rgba(236, 253, 245, 0.85) 50%, rgba(187, 247, 208, 0.9) 100%);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(34, 197, 94, 0.2), 0 2px 10px rgba(22, 163, 74, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.4);
}
.app-header .app-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #14532d;
  text-shadow: 0 1px 2px rgba(220, 252, 231, 0.5);
}
.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.role-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  background: rgba(220, 252, 231, 0.8);
  color: #166534;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border: 1px solid rgba(34, 197, 94, 0.5);
}
.agency-block {
  background: linear-gradient(135deg, rgba(236, 253, 245, 0.9), rgba(220, 252, 231, 0.8));
  color: #14532d;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(34, 197, 94, 0.6);
  text-align: center;
}
#logoutBtn { background: rgba(220, 252, 231, 0.9); color: #166534; border: 1px solid rgba(34, 197, 94, 0.4); }
#logoutBtn:hover { background: #dcfce7; }

/* Cards */
.card {
  background: linear-gradient(165deg, rgba(255,255,255,0.7) 0%, rgba(236, 253, 245, 0.35) 30%, rgba(220, 252, 231, 0.45) 100%);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(34, 197, 94, 0.1), 0 2px 8px rgba(22, 163, 74, 0.08);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.25rem;
  border: 1px solid rgba(34, 197, 94, 0.3);
  backdrop-filter: blur(6px);
  width: 100%;
  text-align: center;
}
.card-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #166534;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
input[type="file"] {
  font-size: 0.9rem;
  padding: 0.5rem 0;
  max-width: 100%;
}

.demo-creds {
  margin-top: 1.5rem;
  padding: 1rem;
  background: rgba(220, 252, 231, 0.4);
  border: 1px solid rgba(34, 197, 94, 0.5);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}
.demo-title { font-weight: 600; color: var(--text-muted); margin-bottom: 0.5rem; }
.demo-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.demo-table th, .demo-table td { padding: 0.35rem 0.5rem; text-align: left; border-bottom: 1px solid rgba(34, 197, 94, 0.3); }
.demo-table th { font-weight: 600; color: var(--text); }

.form-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.search-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
  justify-content: center;
}
.search-row .form-group { margin-bottom: 0; text-align: left; }
.search-row input[type="text"] { min-width: 220px; }
.search-row .month-wrap input {
  width: 150px;
  min-width: 150px;
  cursor: pointer;
}

/* Results */
.result-card .toolbar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}
.result-card .btn-secondary:nth-of-type(1) {
  background: linear-gradient(180deg, #dcfce7 0%, #bbf7d0 100%);
  color: #14532d;
  border: 1px solid rgba(34, 197, 94, 0.5);
}
.result-card .btn-secondary:nth-of-type(1):hover { background: linear-gradient(180deg, #bbf7d0 0%, #86efac 100%); }
.result-card .btn-secondary:nth-of-type(2) {
  background: linear-gradient(180deg, #d1fae5 0%, #a7f3d0 100%);
  color: #166534;
  border: 1px solid rgba(34, 197, 94, 0.5);
}
.result-card .btn-secondary:nth-of-type(2):hover { background: linear-gradient(180deg, #a7f3d0 0%, #5eead4 100%); }

.no-data {
  color: #166534;
  font-size: 0.95rem;
  padding: 2rem;
  text-align: center;
  background: linear-gradient(135deg, rgba(236, 253, 245, 0.5), rgba(220, 252, 231, 0.5));
  border-radius: var(--radius-sm);
  border: 2px dashed rgba(34, 197, 94, 0.5);
  margin: 0 auto;
}
.result-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(34, 197, 94, 0.35);
  box-shadow: 0 2px 10px rgba(34, 197, 94, 0.08);
}
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { padding: 0.65rem 1rem; text-align: left; border-bottom: 1px solid rgba(34, 197, 94, 0.2); }
th {
  background: linear-gradient(180deg, rgba(220, 252, 231, 0.95) 0%, rgba(236, 253, 245, 0.9) 100%);
  color: #14532d;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid rgba(34, 197, 94, 0.4);
}
tr:last-child td { border-bottom: none; }
tr:nth-child(even) td { background: rgba(236, 253, 245, 0.25); }
tr:hover td { background: rgba(220, 252, 231, 0.4); }
td { color: var(--text); }

/* Apply form in app */
.apply-form-inner { text-align: left; max-width: 440px; margin: 0 auto; }
.card-desc { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 1rem; }

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .page { padding: 1rem; max-width: 100%; }
  .login-wrap { min-height: 100vh; padding: 1rem; align-items: stretch; padding-top: 2rem; }
  .login-card { max-width: 100%; padding: 1.5rem 1.25rem; }
  .login-card h1 { font-size: 1.5rem; }
  .app-header { flex-direction: column; align-items: stretch; gap: 0.75rem; padding: 1rem; }
  .app-header .app-title { font-size: 1.2rem; text-align: center; }
  .header-right { justify-content: center; flex-wrap: wrap; }
  .card { padding: 1.25rem 1rem; }
  .search-row { flex-direction: column; align-items: stretch; gap: 1rem; }
  .search-row .form-group, .search-row input[type="text"], .search-row .month-wrap input { min-width: 0; width: 100%; }
  .search-row .btn-accent { width: 100%; min-height: 48px; }
  .result-card .toolbar { flex-direction: column; }
  .result-card .toolbar .btn { width: 100%; min-height: 48px; }
  table { font-size: 0.8rem; }
  th, td { padding: 0.5rem 0.6rem; }
  .btn { min-height: 44px; }
}

@media (max-width: 480px) {
  .page { padding: 0.75rem; }
  .login-card { padding: 1.25rem 1rem; }
  .login-card h1 { font-size: 1.35rem; }
  input[type="text"], input[type="password"], input[type="email"], input[type="tel"] {
    font-size: 16px;
    padding: 0.85rem 1rem;
  }
  .app-header .app-title { font-size: 1.1rem; }
  .role-badge { font-size: 0.7rem; padding: 0.35rem 0.65rem; }
  #logoutBtn { width: 100%; }
  .card-title { font-size: 0.8rem; }
  th { font-size: 0.7rem; }
  td { font-size: 0.75rem; }
  .no-data { padding: 1.5rem 1rem; font-size: 0.9rem; }
}
