/* ── Reset & Base ── */
* { box-sizing: border-box; margin: 0; padding: 0; }

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

body {
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  background: #00070A;
  color: #cbd5e1;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Login Screen ── */
.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #00070A;
  z-index: 1000;
}
.login-card {
  text-align: center;
  padding: 3rem 2.5rem;
  border-radius: 1rem;
  background: rgba(25, 32, 35, 0.92);
  border: 1px solid rgba(0, 179, 179, 0.2);
  max-width: 400px;
  width: 100%;
}
.login-title {
  font-size: 2rem;
  font-weight: 800;
  color: #00B3B3;
  margin-bottom: 0.5rem;
}
.login-subtitle {
  color: #94a3b8;
  font-size: 0.95rem;
  margin-bottom: 2rem;
}
.login-card .g_id_signin {
  display: flex;
  justify-content: center;
}
.login-status {
  margin-top: 1.25rem;
  font-size: 0.85rem;
  color: #94a3b8;
}
.login-status.error {
  color: #f87171;
}
.btn-google {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  background: #fff;
  color: #3c4043;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: 0.5rem;
  border: 1px solid #dadce0;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}
.btn-google:hover {
  background: #f7f8f8;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* ── Header ── */
.header {
  background: #00070A;
  color: #fff;
  padding: 2.5rem 1.5rem 2rem;
  text-align: center;
}
.header h1 {
  font-size: 2rem;
  font-weight: 800;
  color: #00B3B3;
}
.header .subtitle {
  color: #94a3b8;
  margin-top: 0.35rem;
  font-size: 0.95rem;
}

/* ── User Bar ── */
.header-top {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
}
.user-bar {
  font-size: 0.85rem;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.user-bar strong {
  color: #e2e8f0;
  font-weight: 600;
}
.separator {
  color: #334155;
}
.sign-out {
  color: #64748b;
  text-decoration: none;
  transition: color 0.2s;
}
.sign-out:hover {
  color: #00B3B3;
}
.role-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  background: rgba(34, 211, 238, 0.2);
  color: #22D3EE;
  letter-spacing: 0.04em;
}

/* ── Container ── */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ── Navigation Tabs ── */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid rgba(0, 179, 179, 0.2);
  padding-bottom: 0;
}
.tab {
  padding: 0.6rem 1.25rem;
  border: none;
  background: none;
  font-size: 0.95rem;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.2s, border-color 0.2s;
  font-family: inherit;
}
.tab:hover { color: #cbd5e1; }
.tab.active {
  color: #00B3B3;
  border-bottom-color: #00B3B3;
}

/* ── Views ── */
.hidden { display: none !important; }

/* ── Form ── */
.form-group {
  margin-bottom: 1.25rem;
}
.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  color: #94a3b8;
}
.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid rgba(0, 179, 179, 0.3);
  border-radius: 0.75rem;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: rgba(25, 32, 35, 0.92);
  color: #e2e8f0;
}
.form-group input::placeholder,
.form-group textarea::placeholder {
  color: #475569;
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #00B3B3;
  box-shadow: 0 0 0 3px rgba(0, 179, 179, 0.15);
}
.form-group textarea { resize: vertical; }

/* ── Buttons ── */
.btn {
  padding: 0.65rem 1.5rem;
  border: none;
  border-radius: 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  font-family: inherit;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: #00B3B3;
  color: #00070A;
  width: 100%;
}
.btn-primary:hover { background: #008383; }
.btn-primary:disabled {
  background: #334155;
  color: #64748b;
  cursor: not-allowed;
}
.btn-back {
  background: none;
  color: #00B3B3;
  padding: 0.5rem 0;
  margin-bottom: 1rem;
  font-weight: 500;
}
.btn-back:hover { color: #22D3EE; }

/* ── Ticket List ── */
.ticket-list { display: flex; flex-direction: column; gap: 0.75rem; }

.ticket-card {
  background: rgba(25, 32, 35, 0.92);
  border: 1px solid rgba(0, 179, 179, 0.2);
  border-radius: 1rem;
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(4px);
}
.ticket-card:hover {
  border-color: rgba(0, 179, 179, 0.5);
  transform: scale(1.01);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);
}
.ticket-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}
.ticket-card-title {
  font-weight: 600;
  font-size: 1rem;
  color: #e2e8f0;
}
.ticket-card-meta {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 0.25rem;
}

/* ── Status Badge ── */
.status {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.status-open {
  background: rgba(0, 179, 179, 0.2);
  color: #00B3B3;
}
.status-in-progress {
  background: rgba(34, 211, 238, 0.2);
  color: #22D3EE;
}
.status-resolved {
  background: rgba(52, 211, 153, 0.2);
  color: #34D399;
}
.status-closed {
  background: rgba(100, 116, 139, 0.2);
  color: #64748b;
}
.status-estimate-sent {
  background: rgba(251, 191, 36, 0.2);
  color: #fbbf24;
}
.status-approved {
  background: rgba(52, 211, 153, 0.2);
  color: #34D399;
}
.status-rejected {
  background: rgba(248, 113, 113, 0.2);
  color: #f87171;
}
.status-completed {
  background: rgba(34, 211, 238, 0.2);
  color: #22D3EE;
}
.status-paid {
  background: rgba(52, 211, 153, 0.25);
  color: #6ee7b7;
}

/* ── Ticket Detail ── */
.detail-header { margin-bottom: 1.5rem; }
.detail-header h2 {
  font-size: 1.35rem;
  margin-bottom: 0.5rem;
  color: #f1f5f9;
}
.detail-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}
.detail-label {
  font-weight: 600;
  color: #64748b;
  min-width: 80px;
}
.detail-description {
  background: rgba(25, 32, 35, 0.92);
  border: 1px solid rgba(0, 179, 179, 0.15);
  border-radius: 1rem;
  padding: 1rem 1.25rem;
  margin-top: 1rem;
  white-space: pre-wrap;
  font-size: 0.95rem;
  line-height: 1.7;
  color: #cbd5e1;
}
.detail-actions {
  margin-top: 1.5rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.btn-status {
  padding: 0.45rem 1rem;
  border: 1px solid rgba(0, 179, 179, 0.3);
  border-radius: 0.75rem;
  background: rgba(25, 32, 35, 0.92);
  color: #cbd5e1;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.btn-status:hover {
  background: rgba(0, 179, 179, 0.15);
  border-color: #00B3B3;
  color: #00B3B3;
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #64748b;
}
.empty-state h3 { color: #94a3b8; }
.empty-state p { margin-top: 0.5rem; }

/* ── Loading ── */
.loading {
  text-align: center;
  padding: 2rem;
  color: #64748b;
}

/* ── Spinner ── */
.spinner {
  width: 40px;
  height: 40px;
  margin: 1.5rem auto;
  border: 3px solid rgba(0, 179, 179, 0.2);
  border-top-color: #00B3B3;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner-sm {
  width: 24px;
  height: 24px;
  margin: 0 auto 0.75rem;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Estimate Card ── */
.estimate-card {
  margin-top: 1.25rem;
  padding: 1.25rem;
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.25);
  border-radius: 1rem;
}
.estimate-header {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #fbbf24;
  margin-bottom: 0.5rem;
}
.estimate-amount {
  font-size: 1.75rem;
  font-weight: 800;
  color: #fbbf24;
  margin-bottom: 0.35rem;
}
.estimate-notes {
  font-size: 0.9rem;
  color: #94a3b8;
  white-space: pre-wrap;
}

/* ── Estimate Form (Admin) ── */
.estimate-form-section {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: rgba(25, 32, 35, 0.92);
  border: 1px solid rgba(0, 179, 179, 0.2);
  border-radius: 1rem;
}
.estimate-form-section .estimate-header {
  color: #00B3B3;
}
.estimate-form-row {
  display: flex;
  gap: 1rem;
}

/* ── Approve / Reject Buttons ── */
.btn-approve {
  background: #059669;
  color: #fff;
  padding: 0.65rem 1.5rem;
  border-radius: 0.75rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-approve:hover { background: #047857; }
.btn-reject {
  background: none;
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.4);
  padding: 0.65rem 1.5rem;
  border-radius: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-reject:hover {
  background: rgba(248, 113, 113, 0.1);
  border-color: #f87171;
}

/* ── Closed Section (collapsible) ── */
.closed-section {
  margin-top: 1rem;
}
.closed-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(25, 32, 35, 0.6);
  border: 1px solid rgba(100, 116, 139, 0.2);
  border-radius: 0.75rem;
  color: #64748b;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.closed-toggle:hover {
  color: #94a3b8;
  border-color: rgba(100, 116, 139, 0.4);
}
.closed-toggle-icon {
  font-size: 0.7rem;
  transition: transform 0.2s;
}
.closed-list {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.closed-list .ticket-card {
  opacity: 0.6;
}
.closed-list .ticket-card:hover {
  opacity: 1;
}

/* ── Delete Button ── */
.btn-delete {
  background: none;
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.3);
  font-size: 0.85rem;
  padding: 0.45rem 1rem;
}
.btn-delete:hover {
  background: rgba(248, 113, 113, 0.1);
  border-color: #f87171;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: #0e1417;
  color: #00B3B3;
  padding: 0.75rem 1.5rem;
  border-radius: 1rem;
  font-size: 0.9rem;
  z-index: 1000;
  border: 1px solid rgba(0, 179, 179, 0.3);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  transition: opacity 0.3s;
}
.toast.error {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.3);
}

/* ── GIS Button Container ── */
#gsi-button {
  display: flex;
  justify-content: center;
  margin-top: 0.5rem;
}

/* ── Mobile Responsive ── */
@media (max-width: 640px) {
  .header {
    padding: 1.5rem 1rem 1.25rem;
  }
  .header h1 {
    font-size: 1.5rem;
  }
  .header-top {
    justify-content: center;
  }
  .user-bar {
    flex-wrap: wrap;
    justify-content: center;
    font-size: 0.8rem;
  }

  .container {
    padding: 1rem 0.75rem;
  }

  .tabs {
    gap: 0;
  }
  .tab {
    flex: 1;
    text-align: center;
    padding: 0.6rem 0.5rem;
    font-size: 0.85rem;
  }

  .login-card {
    padding: 2rem 1.5rem;
    margin: 0 1rem;
  }
  .login-title {
    font-size: 1.5rem;
  }

  .ticket-card {
    padding: 0.85rem 1rem;
  }
  .ticket-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }
  .ticket-card-title {
    font-size: 0.9rem;
  }

  .detail-header h2 {
    font-size: 1.15rem;
  }
  .detail-row {
    flex-direction: column;
    gap: 0.15rem;
  }
  .detail-label {
    min-width: unset;
  }
  .detail-description {
    padding: 0.85rem 1rem;
    font-size: 0.9rem;
  }
  .detail-actions {
    flex-direction: column;
  }
  .detail-actions .btn,
  .detail-actions .btn-status,
  .detail-actions .btn-approve,
  .detail-actions .btn-reject,
  .detail-actions .btn-delete {
    width: 100%;
    text-align: center;
  }

  .estimate-card {
    padding: 1rem;
  }
  .estimate-amount {
    font-size: 1.4rem;
  }
  .estimate-form-section {
    padding: 1rem;
  }
  .estimate-form-row {
    flex-direction: column;
    gap: 0;
  }

  .toast {
    left: 1rem;
    right: 1rem;
    transform: none;
    text-align: center;
  }

  .closed-toggle {
    font-size: 0.85rem;
    padding: 0.65rem 0.85rem;
  }
}
