/* ═══════════════════════════════════════════════════════════
   Technician Portal - Main Stylesheet
   ═══════════════════════════════════════════════════════════ */

/* ── CSS Variables ───────────────────────────────── */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #3b82f6;
  --secondary: #0f172a;
  --accent: #06b6d4;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1), 0 4px 10px rgba(0,0,0,0.06);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --transition: 0.2s ease;
}

/* ── Reset ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }

img { max-width: 100%; display: block; }

/* ── Utility Classes ─────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 24px; border-radius: var(--radius-sm); font-size: 0.9rem;
  font-weight: 600; cursor: pointer; border: none; transition: var(--transition);
  text-decoration: none; line-height: 1.5;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-lg { padding: 14px 32px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.card {
  background: var(--bg-card); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  padding: 24px; transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-progress { background: #dbeafe; color: #1e40af; }
.badge-completed { background: #d1fae5; color: #065f46; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }

/* ── Typography ──────────────────────────────────── */
.page-title { font-size: 1.75rem; font-weight: 700; color: var(--secondary); }
.section-title { font-size: 1.25rem; font-weight: 600; color: var(--secondary); margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-center { text-align: center; }

/* ── Form Elements ───────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 0.875rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 0.9rem; color: var(--text);
  background: var(--bg-card); transition: var(--transition); font-family: inherit;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-textarea { resize: vertical; min-height: 90px; }
.form-input.error { border-color: var(--danger); }
.form-error { color: var(--danger); font-size: 0.8rem; margin-top: 4px; }
.form-hint { color: var(--text-muted); font-size: 0.78rem; margin-top: 4px; }

/* ── Alert / Toast ───────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm); font-size: 0.875rem;
  margin-bottom: 16px; display: flex; align-items: center; gap: 10px;
}
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  padding: 12px 20px; border-radius: var(--radius-sm); font-size: 0.875rem; font-weight: 500;
  box-shadow: var(--shadow-lg); animation: slideIn 0.3s ease; max-width: 380px;
  display: flex; align-items: center; gap: 10px; cursor: pointer;
}
.toast-success { background: #065f46; color: #fff; }
.toast-error { background: #991b1b; color: #fff; }
.toast-info { background: #1e40af; color: #fff; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ── Spinner ─────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px; border: 2.5px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.6s linear infinite; display: inline-block;
}
.spinner-lg { width: 40px; height: 40px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── NAVBAR ──────────────────────────────────────── */
.navbar {
  background: var(--bg-card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow);
}
.navbar .container { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.navbar-brand {
  font-size: 1.3rem; font-weight: 800; color: var(--secondary);
  display: flex; align-items: center; gap: 10px;
}
.navbar-brand .icon { font-size: 1.5rem; }
.navbar-nav { display: flex; align-items: center; gap: 24px; list-style: none; }
.navbar-nav a { color: var(--text-light); font-weight: 500; font-size: 0.9rem; }
.navbar-nav a:hover, .navbar-nav a.active { color: var(--primary); }
.navbar-nav .nav-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; cursor: pointer;
}
.nav-user-menu { position: relative; }
.nav-dropdown {
  position: absolute; top: 100%; right: 0; margin-top: 8px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  min-width: 200px; padding: 8px 0; display: none; z-index: 200;
}
.nav-dropdown.show { display: block; }
.nav-dropdown a {
  display: block; padding: 10px 20px; color: var(--text); font-size: 0.875rem;
}
.nav-dropdown a:hover { background: var(--border-light); color: var(--primary); }
.nav-dropdown .divider { height: 1px; background: var(--border); margin: 6px 0; }

/* ── HERO ────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, var(--secondary) 0%, #1e3a5f 50%, #0f2b4f 100%);
  color: #fff; padding: 80px 0; position: relative; overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; top: -50%; right: -20%;
  width: 600px; height: 600px; border-radius: 50%;
  background: radial-gradient(circle, rgba(37,99,235,0.3), transparent 70%);
}
.hero::after {
  content: ''; position: absolute; bottom: -30%; left: -10%;
  width: 400px; height: 400px; border-radius: 50%;
  background: radial-gradient(circle, rgba(6,182,212,0.2), transparent 70%);
}
.hero-content { position: relative; z-index: 1; max-width: 650px; }
.hero h1 { font-size: 2.8rem; font-weight: 800; line-height: 1.2; margin-bottom: 20px; }
.hero h1 .accent { color: var(--accent); }
.hero p { font-size: 1.15rem; color: rgba(255,255,255,0.8); margin-bottom: 32px; line-height: 1.7; }
.hero-buttons { display: flex; gap: 14px; flex-wrap: wrap; }

/* ── FEATURES ────────────────────────────────────── */
.features { padding: 80px 0; }
.features-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px; margin-top: 40px;
}
.feature-card {
  text-align: center; padding: 36px 24px;
}
.feature-icon {
  width: 64px; height: 64px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px; font-size: 1.8rem;
}
.feature-icon.frp { background: #dbeafe; }
.feature-icon.telco { background: #d1fae5; }
.feature-icon.profile { background: #fef3c7; }
.feature-card h3 { font-size: 1.1rem; margin-bottom: 8px; color: var(--secondary); }
.feature-card p { color: var(--text-light); font-size: 0.9rem; }

/* ── SERVICES SECTION ────────────────────────────── */
.services { padding: 80px 0; background: #fff; }
.services-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 24px; margin-top: 32px; }
.service-card { position: relative; overflow: hidden; }
.service-card .card-header {
  display: flex; align-items: center; gap: 14px; margin-bottom: 16px;
  padding-bottom: 16px; border-bottom: 1px solid var(--border);
}
.service-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
}
.service-icon.frp { background: #dbeafe; color: var(--primary); }
.service-icon.telco { background: #d1fae5; color: var(--success); }
.service-card h3 { font-size: 1.15rem; }
.service-card ul { list-style: none; margin: 12px 0 0; }
.service-card ul li {
  padding: 6px 0; color: var(--text-light); font-size: 0.9rem;
  display: flex; align-items: center; gap: 8px;
}
.service-card ul li::before { content: '✓'; color: var(--success); font-weight: bold; }

/* ── AUTH PAGES ──────────────────────────────────── */
.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--secondary) 0%, #1e3a5f 100%);
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 440px; background: var(--bg-card);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 40px 36px;
}
.auth-card .auth-logo {
  text-align: center; margin-bottom: 28px;
  font-size: 1.6rem; font-weight: 800; color: var(--secondary);
}
.auth-card h2 { font-size: 1.35rem; text-align: center; margin-bottom: 8px; }
.auth-card .auth-subtitle { text-align: center; color: var(--text-muted); margin-bottom: 28px; font-size: 0.9rem; }
.auth-card .form-group:last-of-type { margin-bottom: 24px; }
.auth-footer { text-align: center; margin-top: 20px; font-size: 0.875rem; color: var(--text-light); }

/* ── DASHBOARD ───────────────────────────────────── */
.dashboard { padding: 32px 0; }
.dashboard-header { margin-bottom: 28px; }
.dashboard-header h1 { font-size: 1.6rem; margin-bottom: 4px; }
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 32px;
}
.stat-card { text-align: center; padding: 20px; }
.stat-card .stat-value { font-size: 2rem; font-weight: 800; color: var(--primary); }
.stat-card .stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card.frp .stat-value { color: var(--primary); }
.stat-card.telco .stat-value { color: var(--success); }
.stat-card.pending .stat-value { color: var(--warning); }
.stat-card.completed .stat-value { color: var(--success); }

.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 768px) { .dashboard-grid { grid-template-columns: 1fr; } }

.request-list { list-style: none; }
.request-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--border-light);
}
.request-item:last-child { border-bottom: none; }
.request-info h4 { font-size: 0.9rem; margin-bottom: 2px; }
.request-info p { font-size: 0.78rem; color: var(--text-muted); }

.activity-list { list-style: none; }
.activity-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border-light); font-size: 0.85rem;
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px; height: 8px; border-radius: 50%; margin-top: 6px;
  flex-shrink: 0; background: var(--primary);
}
.activity-time { color: var(--text-muted); font-size: 0.78rem; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; }

/* ── PROFILE PAGE ────────────────────────────────── */
.profile-page { padding: 32px 0; }
.profile-grid { display: grid; grid-template-columns: 280px 1fr; gap: 24px; }
@media (max-width: 768px) { .profile-grid { grid-template-columns: 1fr; } }
.profile-sidebar { text-align: center; }
.profile-avatar {
  width: 100px; height: 100px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 2.5rem;
  font-weight: 800; display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}
.profile-role { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
.profile-stats { margin-top: 20px; }
.profile-stat { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border-light); font-size: 0.85rem; }
.profile-stat .value { font-weight: 600; }
.tab-nav { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 24px; }
.tab-btn {
  padding: 10px 20px; font-size: 0.875rem; font-weight: 600; color: var(--text-muted);
  background: none; border: none; cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: var(--transition);
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── MODAL ───────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 24px;
}
.modal {
  background: var(--bg-card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.1rem; }
.modal-close {
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: var(--border-light); cursor: pointer; font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center; transition: var(--transition);
}
.modal-close:hover { background: var(--border); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ── Pricing Cards ─────────────────────────────────── */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px; margin-top: 40px;
}
.pricing-card {
  position: relative; text-align: center; padding: 36px 28px;
  border: 2px solid var(--border); transition: var(--transition);
}
.pricing-card:hover { border-color: var(--primary); transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.pricing-card.popular { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.pricing-badge {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  background: var(--primary); color: #fff; padding: 4px 20px;
  border-radius: 20px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
}
.pricing-card .plan-name { font-size: 1.1rem; font-weight: 700; color: var(--secondary); }
.pricing-card .plan-desc { font-size: 0.85rem; color: var(--text-muted); margin: 6px 0 16px; }
.pricing-card .plan-price { font-size: 2.2rem; font-weight: 800; color: var(--primary); }
.pricing-card .plan-price .currency { font-size: 1.1rem; }
.pricing-card .plan-credit { font-size: 0.85rem; color: var(--text-light); margin: 4px 0 16px; }
.pricing-card .plan-credit strong { color: var(--secondary); }
.pricing-card .plan-features { list-style: none; text-align: left; margin: 20px 0; padding: 0; }
.pricing-card .plan-features li {
  padding: 8px 0; font-size: 0.88rem; color: var(--text-light);
  display: flex; align-items: center; gap: 10px;
}
.pricing-card .plan-features li::before { content: '✓'; color: var(--success); font-weight: bold; }

/* ── Credit Badge ──────────────────────────────────── */
.credit-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  padding: 6px 14px; border-radius: 20px; font-weight: 700; font-size: 0.85rem;
  color: #92400e; border: 1px solid #fcd34d;
}
.credit-badge.critical { background: #fee2e2; border-color: #fecaca; color: #991b1b; }
.credit-badge.low { background: #fef3c7; border-color: #fcd34d; color: #92400e; }
.credit-badge.good { background: #d1fae5; border-color: #a7f3d0; color: #065f46; }
.credit-info-card { margin-bottom: 28px; }
.credit-info-card .card-body {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px;
}
.credit-balance { font-size: 2.5rem; font-weight: 800; color: var(--primary); }
.credit-balance .label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.credit-warning {
  margin-top: 12px; padding: 10px 16px; background: #fef3c7; border-radius: var(--radius-sm);
  font-size: 0.85rem; color: #92400e; border: 1px solid #fcd34d;
  display: flex; align-items: center; gap: 10px;
}

/* ── Purchase History ──────────────────────────────── */
.purchase-list { list-style: none; }
.purchase-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border-light); font-size: 0.88rem;
}
.purchase-item:last-child { border-bottom: none; }

/* ── Tech Cards / Online Status ────────────────────── */
.tech-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.tech-card { position: relative; cursor: pointer; }
.tech-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.tech-card .tech-avatar {
  width: 64px; height: 64px; border-radius: 50%; background: var(--primary);
  color: #fff; font-size: 1.4rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center; margin-bottom: 12px;
}
.tech-card .tech-header { display: flex; align-items: flex-start; gap: 14px; }
.tech-card .tech-info { flex: 1; }
.tech-card .tech-name { font-size: 1rem; font-weight: 700; color: var(--secondary); }
.tech-card .tech-spec { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.tech-card .tech-stats { display: flex; gap: 16px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-light); }
.tech-card .tech-stat { text-align: center; }
.tech-card .tech-stat .val { font-weight: 700; font-size: 1rem; }
.tech-card .tech-stat .lbl { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; }
.online-dot {
  width: 12px; height: 12px; border-radius: 50%; display: inline-block;
  flex-shrink: 0; margin-top: 4px;
}
.online-dot.online { background: var(--success); box-shadow: 0 0 6px rgba(16,185,129,0.5); }
.online-dot.offline { background: #cbd5e1; }
.status-toggle { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--border-light); border-radius: var(--radius-sm); margin-bottom: 16px; }
.status-toggle .toggle-switch { position: relative; width: 48px; height: 26px; cursor: pointer; }
.status-toggle .toggle-switch input { opacity: 0; width: 0; height: 0; }
.status-toggle .toggle-slider { position: absolute; inset: 0; background: #cbd5e1; border-radius: 26px; transition: .3s; }
.status-toggle .toggle-slider::before { content: ''; position: absolute; width: 20px; height: 20px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .3s; }
.status-toggle input:checked + .toggle-slider { background: var(--success); }
.status-toggle input:checked + .toggle-slider::before { transform: translateX(22px); }

/* ── Chat Interface ────────────────────────────────── */
.chat-page { padding: 24px 0; }
.chat-layout { display: grid; grid-template-columns: 320px 1fr; gap: 0; height: calc(100vh - 80px); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: var(--bg-card); }
@media (max-width: 768px) { .chat-layout { grid-template-columns: 1fr; } .chat-sidebar { display: none; } }
.chat-sidebar { border-right: 1px solid var(--border); overflow-y: auto; }
.chat-sidebar-header { padding: 16px; border-bottom: 1px solid var(--border); font-weight: 700; }
.chat-contact {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  cursor: pointer; border-bottom: 1px solid var(--border-light); transition: .15s;
}
.chat-contact:hover, .chat-contact.active { background: var(--border-light); }
.chat-contact .contact-avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--primary);
  color: #fff; font-weight: 700; font-size: 0.8rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.chat-contact .contact-info { flex: 1; min-width: 0; }
.chat-contact .contact-name { font-size: 0.875rem; font-weight: 600; }
.chat-contact .contact-role { font-size: 0.72rem; color: var(--text-muted); }
.chat-unread { background: var(--danger); color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 0.7rem; font-weight: 700; }
.chat-main { display: flex; flex-direction: column; }
.chat-main-header {
  padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex;
  align-items: center; gap: 12px; flex-shrink: 0;
}
.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { max-width: 70%; padding: 10px 14px; border-radius: 16px; font-size: 0.875rem; line-height: 1.5; position: relative; }
.chat-msg.sent { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.received { align-self: flex-start; background: var(--border-light); color: var(--text); border-bottom-left-radius: 4px; }
.chat-msg .msg-time { font-size: 0.68rem; opacity: 0.7; margin-top: 4px; text-align: right; }
.chat-input-area { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; flex-shrink: 0; }
.chat-input-area input { flex: 1; }
.chat-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-muted); flex-direction: column; gap: 8px; }

/* ── Admin Panel ──────────────────────────────────── */
.admin-page { padding: 24px 0; }
.admin-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 28px; }
.admin-stat { text-align: center; padding: 18px; }
.admin-stat .val { font-size: 1.8rem; font-weight: 800; color: var(--primary); }
.admin-stat .lbl { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table th { text-align: left; padding: 10px 14px; background: var(--border-light); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; color: var(--text-light); border-bottom: 2px solid var(--border); }
.data-table td { padding: 10px 14px; border-bottom: 1px solid var(--border-light); }
.data-table tr:hover { background: var(--border-light); }
.table-wrap { overflow-x: auto; }

/* ── Tech Detail Page ─────────────────────────────── */
.tech-detail-page { padding: 32px 0; }
.tech-detail-header { display: flex; gap: 24px; margin-bottom: 28px; }
@media (max-width: 640px) { .tech-detail-header { flex-direction: column; align-items: center; text-align: center; } }
.tech-detail-avatar {
  width: 96px; height: 96px; border-radius: 50%; background: var(--primary);
  color: #fff; font-size: 2rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.tech-detail-info h2 { font-size: 1.5rem; margin-bottom: 2px; }
.tech-detail-info .detail-meta { font-size: 0.85rem; color: var(--text-light); }
.tech-detail-stats { display: flex; gap: 24px; margin-top: 12px; }

/* ── Buy Credits Page ──────────────────────────────── */
.buy-page { padding: 32px 0; }
.buy-header { text-align: center; margin-bottom: 40px; }
.buy-header h1 { font-size: 1.8rem; margin-bottom: 8px; }
.checkout-modal { text-align: center; padding: 20px 0; }
.checkout-modal .checkout-icon { font-size: 3rem; margin-bottom: 16px; }
.checkout-modal .checkout-detail { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.checkout-modal .checkout-total { display: flex; justify-content: space-between; padding: 14px 0; font-weight: 700; font-size: 1.1rem; }

/* ── Footer ──────────────────────────────────────── */
.footer {
  background: var(--secondary); color: rgba(255,255,255,0.7);
  text-align: center; padding: 24px 0; font-size: 0.85rem; margin-top: 80px;
}

/* ── Responsive ──────────────────────────────────── */
/* Tablet & Phone (≤1024px) — hamburger nav on both */
@media (max-width: 1024px) {
  .container { padding: 0 18px; }

  /* ═══ CSS handles mobile nav via .navbar-nav-mobile class added by JS ═══ */
  .nav-user-menu { width: 100%; }
  .nav-dropdown { position: static; box-shadow: none; border: none; margin-top: 0; padding: 0; min-width: 0; }
  .nav-dropdown a { padding: 12px 12px; font-size: 0.9rem; }
  .nav-dropdown .divider { margin: 4px 0; }
  .nav-user-menu .nav-avatar { margin-left: auto; }

  .dashboard-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .chat-layout { grid-template-columns: 260px 1fr; }
  .chat-messages { padding: 14px; }
  .data-table { font-size: 0.78rem; }
  .data-table th, .data-table td { padding: 8px 10px; }
  .pricing-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
  .services-grid { grid-template-columns: 1fr; }
  .tech-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .tab-nav { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .tab-btn { white-space: nowrap; font-size: 0.8rem; padding: 8px 14px; }
  .admin-stats-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Phone (≤768px) */
@media (max-width: 768px) {
  html { font-size: 15px; }
  .container { padding: 0 14px; }
  .btn { padding: 10px 18px; font-size: 0.85rem; }
  .btn-lg { padding: 12px 24px; font-size: 0.95rem; }
  .card { padding: 18px; }
  .page-title { font-size: 1.35rem; }
  .section-title { font-size: 1.1rem; }

  /* Auth */
  .auth-page { padding: 16px; }
  .auth-card { max-width: 100%; padding: 28px 20px; border-radius: var(--radius); }

  /* Hero */
  .hero { padding: 48px 0; text-align: center; }
  .hero h1 { font-size: 1.7rem; }
  .hero p { font-size: 0.95rem; }
  .hero-content { max-width: 100%; }
  .hero-buttons { justify-content: center; }

  /* Stats */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 16px 10px; }
  .stat-card .stat-value { font-size: 1.5rem; }
  .admin-stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  /* Dashboard grid */
  .dashboard-grid { grid-template-columns: 1fr; gap: 16px; }
  .credit-info-card .card-body { flex-direction: column; align-items: flex-start; }
  .credit-balance { font-size: 2rem; }

  /* Request/purchase items */
  .request-item { flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px; }
  .purchase-item { flex-direction: column; align-items: flex-start; gap: 6px; }

  /* Profile */
  .profile-grid { grid-template-columns: 1fr; gap: 16px; }
  .profile-sidebar { padding: 20px; }
  .profile-avatar { width: 80px; height: 80px; font-size: 2rem; }
  .tab-nav { gap: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab-btn { font-size: 0.75rem; padding: 8px 12px; white-space: nowrap; }

  /* Tables */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .data-table { font-size: 0.75rem; min-width: 600px; }
  .data-table th, .data-table td { padding: 6px 8px; }

  /* Chat */
  .chat-page { padding: 12px 0; }
  .chat-layout { grid-template-columns: 1fr; height: calc(100vh - 56px); border: none; border-radius: 0; position: relative; }
  .chat-sidebar { display: none; position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--bg-card); }
  .chat-sidebar.mobile-visible { display: block; }
  .chat-contact { padding: 12px 14px; }
  .chat-main-header { padding: 10px 14px; }
  .chat-messages { padding: 12px; }
  .chat-msg { max-width: 85%; font-size: 0.85rem; padding: 8px 12px; }
  .chat-input-area { padding: 10px 12px; gap: 8px; }
  .chat-input-area input { font-size: 1rem; } /* prevent zoom on iOS */
  .chat-input-area .btn { padding: 10px 14px; font-size: 0.85rem; }
  .btn-back-contacts { display: inline-flex !important; }

  /* Pricing */
  .pricing-grid { grid-template-columns: 1fr; gap: 16px; max-width: 400px; margin: 24px auto 0; }
  .pricing-card { padding: 24px 20px; }

  /* Tech cards */
  .tech-grid { grid-template-columns: 1fr; max-width: 500px; margin: 0 auto; }

  /* Tech detail */
  .tech-detail-header { flex-direction: column; align-items: center; text-align: center; gap: 12px; }
  .tech-detail-avatar { width: 72px; height: 72px; font-size: 1.5rem; }
  .tech-detail-info h2 { font-size: 1.2rem; }
  .tech-detail-stats { justify-content: center; flex-wrap: wrap; gap: 12px; }

  /* Features & Services */
  .features, .services { padding: 40px 0; }
  .features-grid { grid-template-columns: 1fr; gap: 16px; }
  .services-grid { grid-template-columns: 1fr; }

  /* Modal */
  .modal-overlay { padding: 12px; align-items: flex-end; }
  .modal { max-width: 100%; max-height: 85vh; border-radius: var(--radius) var(--radius) 0 0; }
  .modal-header { padding: 14px 18px; }
  .modal-body { padding: 18px; }
  .modal-footer { padding: 12px 18px; flex-wrap: wrap; }
  .modal-footer .btn { flex: 1; min-width: 0; }

  /* Toast */
  .toast-container { top: 10px; right: 10px; left: 10px; }
  .toast { max-width: 100%; font-size: 0.82rem; }

  /* Buy page */
  .buy-header h1 { font-size: 1.4rem; }
  .checkout-modal .checkout-detail { font-size: 0.85rem; }

  /* Footer */
  .footer { margin-top: 40px; padding: 18px 0; font-size: 0.78rem; }
}

/* Small phone (≤480px) */
@media (max-width: 480px) {
  html { font-size: 14px; }
  .container { padding: 0 10px; }
  .card { padding: 14px; border-radius: var(--radius-sm); }
  .btn { padding: 8px 14px; font-size: 0.82rem; width: 100%; }
  .btn.btn-sm { width: auto; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px 8px; }
  .stat-card .stat-value { font-size: 1.3rem; }
  .stat-card .stat-label { font-size: 0.7rem; }
  .admin-stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .admin-stat { padding: 12px 8px; }
  .admin-stat .val { font-size: 1.3rem; }
  .page-title { font-size: 1.2rem; }
  .section-title { font-size: 1rem; }
  .hero { padding: 36px 0; }
  .hero h1 { font-size: 1.4rem; }
  .hero p { font-size: 0.88rem; }
  .tab-btn { font-size: 0.7rem; padding: 6px 10px; }
  .modal { border-radius: 12px 12px 0 0; }
  .chat-msg { max-width: 90%; }
  .pricing-card { padding: 20px 16px; }
  .pricing-card .plan-price { font-size: 1.8rem; }
  .profile-sidebar { padding: 16px; }
  .form-input, .form-select, .form-textarea { font-size: 1rem; padding: 9px 12px; } /* 16px equiv to prevent iOS zoom */
  .data-table { min-width: 480px; font-size: 0.7rem; }
  .dashboard-header h1 { font-size: 1.2rem; }
}

/* Navbar mobile state — driven by JS class, not media query */
.navbar-nav-mobile {
  flex-direction: column !important;
  position: absolute !important; top: 56px !important; left: 0 !important; right: 0 !important;
  background: var(--bg-card) !important;
  border-bottom: 1px solid var(--border) !important;
  padding: 8px 14px !important; gap: 4px !important;
  box-shadow: var(--shadow-lg) !important;
  z-index: 99 !important;
  max-height: calc(100vh - 56px) !important;
  overflow-y: auto !important;
}
.navbar-nav-mobile li { width: 100% !important; }
.navbar-nav-mobile a {
  display: block !important; padding: 14px 12px !important; border-radius: var(--radius-sm) !important;
  font-size: 1rem !important; color: var(--text) !important;
}
.navbar-nav-mobile a:hover { background: var(--border-light) !important; }
.navbar-nav-mobile a.active { background: #dbeafe !important; color: var(--primary-dark) !important; font-weight: 700 !important; }

/* When mobile nav is toggled open, override display:none inline style */
.navbar-nav-mobile.mobile-open { display: flex !important; }

/* ── Navbar mobile menu toggle button ────────────── */
.nav-menu-toggle {
  display: none;
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--primary); background: var(--bg-card);
  font-size: 1.4rem; cursor: pointer; align-items: center;
  justify-content: center; color: var(--primary); line-height: 1;
  transition: all 0.2s ease; flex-shrink: 0; margin-left: auto;
  -webkit-tap-highlight-color: transparent;
}
.nav-menu-toggle:active {
  background: var(--primary); color: #fff;
}

/* Mobile menu backdrop */
.nav-backdrop {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,0.35);
  z-index: 98; animation: fadeIn 0.2s ease;
}
.nav-backdrop.show { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Back-to-contacts button (chat mobile) */
.btn-back-contacts { display: none !important; }

/* ── Loading overlay ─────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0; background: rgba(255,255,255,0.8);
  display: flex; align-items: center; justify-content: center; z-index: 5000;
}
