/* ============================================================
   Aflopy Client Portal — Shared CSS
   ============================================================ */

:root {
  --primary:      #4facfe;
  --secondary:    #a78bfa;
  --accent:       #00f2fe;
  --success:      #34d399;
  --warning:      #fbbf24;
  --danger:       #f87171;
  --bg:           #080c18;
  --surface:      #0d1526;
  --surface2:     #111927;
  --glass:        rgba(255,255,255,0.04);
  --glass-border: rgba(255,255,255,0.08);
  --text:         #e2e8f0;
  --text-muted:   #64748b;
  --sidebar-w:    260px;
  --font-body:    'Inter', sans-serif;
  --font-heading: 'Outfit', sans-serif;
  --radius:       12px;
  --shadow:       0 8px 32px rgba(0,0,0,0.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  font-size: 0.925rem;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--accent); }

h1,h2,h3,h4,h5 { font-family: var(--font-heading); font-weight: 700; line-height: 1.25; }

/* ── Layout ── */
.cp-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.cp-sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--glass-border);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  transition: transform .3s;
}

.cp-sidebar-logo {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.cp-sidebar-logo img { height: 28px; border-radius: 4px; }
.cp-sidebar-logo .site-name {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.1rem;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.cp-sidebar-logo .portal-tag {
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  display: block;
  margin-top: -4px;
}

.cp-client-badge {
  padding: 16px 20px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.cp-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  flex-shrink: 0;
}
.cp-client-name { font-weight: 600; font-size: 0.88rem; }
.cp-client-role { font-size: 0.72rem; color: var(--text-muted); }

.cp-nav { padding: 16px 12px; flex: 1; }
.cp-nav-section { margin-bottom: 8px; }
.cp-nav-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 8px 8px;
}
.cp-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9rem;
  transition: all .2s;
  position: relative;
}
.cp-nav a:hover { background: var(--glass); color: var(--text); }
.cp-nav a.active {
  background: linear-gradient(90deg, rgba(79,172,254,.15), rgba(0,242,254,.08));
  color: var(--primary);
  border-left: 3px solid var(--primary);
}
.cp-nav a i { width: 18px; text-align: center; font-size: 0.95rem; }
.cp-nav .badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

.cp-sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--glass-border);
}
.cp-sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--danger);
  font-weight: 500;
  font-size: 0.9rem;
  transition: background .2s;
}
.cp-sidebar-footer a:hover { background: rgba(248,113,113,.1); color: var(--danger); }

/* ── Main content ── */
.cp-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.cp-topbar {
  padding: 16px 32px;
  background: rgba(13,21,38,.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
}
.cp-topbar-title { font-family: var(--font-heading); font-size: 1.15rem; font-weight: 700; }
.cp-topbar-right { display: flex; align-items: center; gap: 16px; }

.cp-notif-btn {
  position: relative;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  transition: all .2s;
  text-decoration: none;
}
.cp-notif-btn:hover { color: var(--text); background: rgba(255,255,255,.08); }
.cp-notif-btn .dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--surface);
}

.cp-content {
  padding: 32px;
  flex: 1;
}

/* ── Cards / Glass panels ── */
.card {
  background: var(--glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color .2s, transform .2s;
}
.card:hover { border-color: rgba(79,172,254,.25); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--glass-border);
}
.card-title { font-size: 1rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-title i { color: var(--primary); }

/* ── Stat cards ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all .25s;
}
.stat-card:hover { border-color: rgba(79,172,254,.3); transform: translateY(-2px); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.stat-info { min-width: 0; }
.stat-value { font-family: var(--font-heading); font-size: 1.6rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }

/* ── Grid helpers ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 24px; }
.mb-24 { margin-bottom: 24px; }
.mb-32 { margin-bottom: 32px; }

/* ── Tables ── */
.cp-table { width: 100%; border-collapse: collapse; }
.cp-table th, .cp-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--glass-border);
  font-size: 0.88rem;
}
.cp-table th { color: var(--text-muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: .05em; }
.cp-table tr:last-child td { border-bottom: none; }
.cp-table tbody tr:hover { background: rgba(255,255,255,.02); }
.table-wrap { overflow-x: auto; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.form-control {
  width: 100%;
  padding: 10px 14px;
  background: rgba(0,0,0,.25);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  transition: border-color .2s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,172,254,.12); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control option { background: var(--surface); color: var(--text); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .2s;
  text-decoration: none;
}
.btn-primary {
  background: linear-gradient(90deg, var(--primary), var(--accent));
  color: #000;
}
.btn-primary:hover { opacity: .88; transform: translateY(-1px); color: #000; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: rgba(79,172,254,.06); }
.btn-danger {
  background: rgba(248,113,113,.15);
  border: 1px solid rgba(248,113,113,.3);
  color: var(--danger);
}
.btn-danger:hover { background: rgba(248,113,113,.25); color: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-icon { padding: 8px; border-radius: 8px; }

/* ── Chat ── */
.chat-wrap { display: flex; flex-direction: column; gap: 14px; max-height: 460px; overflow-y: auto; padding: 4px 0; }
.chat-msg { display: flex; gap: 10px; }
.chat-msg.mine { flex-direction: row-reverse; }
.chat-bubble {
  max-width: 70%;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.5;
}
.chat-msg:not(.mine) .chat-bubble { background: var(--glass); border: 1px solid var(--glass-border); }
.chat-msg.mine .chat-bubble { background: linear-gradient(135deg, rgba(79,172,254,.25), rgba(167,139,250,.18)); border: 1px solid rgba(79,172,254,.2); }
.chat-meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; }
.chat-msg.mine .chat-meta { text-align: right; }
.chat-input-wrap { display: flex; gap: 10px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--glass-border); }
.chat-avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--secondary)); display: flex; align-items: center; justify-content: center; font-size: 0.78rem; font-weight: 700; flex-shrink: 0; }
.admin-avatar { background: linear-gradient(135deg, #34d399, #059669); }

/* ── Progress ── */
.progress-wrap { margin: 8px 0; }
.progress-bar-bg { background: rgba(255,255,255,.07); border-radius: 99px; height: 8px; overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 99px; transition: width .5s ease; }

/* ── Timeline ── */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content:''; position:absolute; left:7px; top:0; bottom:0; width:2px; background: var(--glass-border); }
.timeline-item { position: relative; margin-bottom: 24px; }
.timeline-dot {
  position: absolute;
  left: -24px;
  top: 4px;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--surface);
}
.timeline-item h4 { font-size: 0.9rem; margin-bottom: 4px; }
.timeline-item p { font-size: 0.8rem; color: var(--text-muted); }

/* ── Alerts ── */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 0.88rem; margin-bottom: 16px; display: flex; gap: 10px; align-items: center; }
.alert-success { background: rgba(52,211,153,.1); border: 1px solid rgba(52,211,153,.25); color: #34d399; }
.alert-error   { background: rgba(248,113,113,.1); border: 1px solid rgba(248,113,113,.25); color: #f87171; }
.alert-info    { background: rgba(79,172,254,.1); border: 1px solid rgba(79,172,254,.25); color: var(--primary); }
.alert-warning { background: rgba(251,191,36,.1); border: 1px solid rgba(251,191,36,.25); color: var(--warning); }

/* ── Login page ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(79,172,254,.07) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(167,139,250,.07) 0%, transparent 50%);
}
.login-box {
  width: 100%;
  max-width: 420px;
  padding: 40px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .site-name { font-family: var(--font-heading); font-size: 1.6rem; font-weight: 800; background: linear-gradient(90deg, var(--primary), var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.login-logo .subtitle { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }

/* ── Invoice print ── */
@media print {
  .cp-sidebar, .cp-topbar, .no-print { display: none !important; }
  .cp-main { margin-left: 0 !important; }
  .invoice-wrap { box-shadow: none; }
}
.invoice-wrap { background: var(--surface); border: 1px solid var(--glass-border); border-radius: var(--radius); padding: 40px; max-width: 800px; }
.invoice-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 32px; }
.invoice-number { font-family: var(--font-heading); font-size: 1.6rem; color: var(--primary); }
.invoice-table { width: 100%; border-collapse: collapse; margin: 24px 0; }
.invoice-table th, .invoice-table td { padding: 12px 16px; border-bottom: 1px solid var(--glass-border); text-align: left; }
.invoice-table th { background: rgba(0,0,0,.2); color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; }
.invoice-totals { text-align: right; }
.invoice-totals td { padding: 6px 16px; }
.invoice-total-row { font-weight: 700; font-size: 1.1rem; color: var(--primary); }

/* ── File upload ── */
.file-drop {
  border: 2px dashed var(--glass-border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
}
.file-drop:hover, .file-drop.dragover { border-color: var(--primary); background: rgba(79,172,254,.04); }
.file-drop i { font-size: 2rem; color: var(--text-muted); margin-bottom: 8px; display: block; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .cp-sidebar { transform: translateX(-100%); z-index: 999; box-shadow: 4px 0 24px rgba(0,0,0,0.5); }
  .cp-sidebar.open { transform: translateX(0); }
  .cp-main { margin-left: 0; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .cp-content { padding: 20px; }
  .cp-topbar { padding: 14px 20px; padding-left: 60px; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.2); }

/* ── Misc ── */
.gradient-text { background: linear-gradient(90deg, var(--primary), var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-right { text-align: right; }
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; margin-bottom: 12px; display: block; opacity: .4; }
.empty-state p { font-size: 0.9rem; }

/* ── Notification badge on icon ── */
.has-notif::after {
  content: ''; position: absolute; top: 8px; right: 8px;
  width: 6px; height: 6px; background: var(--danger);
  border-radius: 50%;
}

/* Floating mobile menu button */
.mobile-menu-fab {
  display: none;
  position: fixed;
  top: 14px; left: 14px;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
}
@media (max-width: 900px) { .mobile-menu-fab { display: flex; align-items:center; } }
