/* Vision Double - Custom Styles (Laravel build) */
:root {
  --primary: #1a3a6b;
  --primary-light: #2450a0;
  --accent: #e8a020;
  --accent-light: #f5c060;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --surface: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --sidebar-w: 260px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background: var(--surface); color: var(--text); }

/* Sidebar */
.sidebar {
  position: fixed; left: 0; top: 0; height: 100vh; width: var(--sidebar-w);
  background: linear-gradient(180deg, #0f2347 0%, #1a3a6b 60%, #1e4480 100%);
  color: white; z-index: 100; overflow-y: auto; transition: transform .3s;
  display: flex; flex-direction: column;
}
.sidebar-logo { padding: 20px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-logo h1 { font-size: 1.25rem; font-weight: 800; letter-spacing: -.5px; }
.sidebar-logo span { font-size: .75rem; opacity: .6; }
.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section { padding: 8px 16px 4px; font-size: .65rem; text-transform: uppercase; letter-spacing: 1px; opacity: .45; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 20px;
  color: rgba(255,255,255,.75); font-size: .84rem; font-weight: 500;
  cursor: pointer; border-radius: 0; transition: all .15s; text-decoration: none;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: white; border-left-color: rgba(255,255,255,.3); }
.nav-item.active { background: rgba(232,160,32,.15); color: white; border-left-color: var(--accent); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-badge { margin-left: auto; background: var(--accent); color: #000; font-size: .65rem; font-weight: 700; padding: 1px 6px; border-radius: 10px; }

/* Top bar */
.topbar {
  position: fixed; left: var(--sidebar-w); right: 0; top: 0; height: 60px;
  background: white; border-bottom: 1px solid var(--border); z-index: 90;
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
  gap: 16px;
}
.topbar-title { font-size: 1rem; font-weight: 700; color: var(--primary); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.avatar { width: 34px; height: 34px; background: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-size: .75rem; font-weight: 700; cursor: pointer; }
.notif-btn { position: relative; background: none; border: none; cursor: pointer; padding: 6px; color: var(--muted); }
.notif-dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; background: var(--danger); border-radius: 50%; border: 2px solid white; }

/* Main content */
.main { margin-left: var(--sidebar-w); padding-top: 60px; min-height: 100vh; }
.page { padding: 28px; }

/* Cards */
.card { background: var(--card); border-radius: 12px; border: 1px solid var(--border); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.card-title { font-size: .9rem; font-weight: 700; }
.card-body { padding: 20px; }

/* Stat cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: white; border-radius: 12px; padding: 18px 20px; border: 1px solid var(--border); position: relative; overflow: hidden; }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; }
.stat-card.blue::before { background: linear-gradient(90deg, #1a3a6b, #2450a0); }
.stat-card.gold::before { background: linear-gradient(90deg, #e8a020, #f5c060); }
.stat-card.green::before { background: linear-gradient(90deg, #16a34a, #22c55e); }
.stat-card.red::before { background: linear-gradient(90deg, #dc2626, #ef4444); }
.stat-card.purple::before { background: linear-gradient(90deg, #7c3aed, #a78bfa); }
.stat-card.teal::before { background: linear-gradient(90deg, #0d9488, #2dd4bf); }
.stat-label { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 6px; }
.stat-value { font-size: 1.8rem; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-sub { font-size: .72rem; color: var(--muted); margin-top: 4px; }
.stat-trend { font-size: .72rem; font-weight: 600; margin-top: 6px; }
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th { text-align: left; padding: 10px 14px; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); border-bottom: 2px solid var(--border); background: #f8fafc; }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 6px; font-size: .7rem; font-weight: 600; }
.badge-success { background: #dcfce7; color: #16a34a; }
.badge-warning { background: #fef3c7; color: #d97706; }
.badge-danger { background: #fee2e2; color: #dc2626; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-purple { background: #ede9fe; color: #7c3aed; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 16px; border-radius: 8px; font-size: .84rem; font-weight: 600; cursor: pointer; border: none; transition: all .15s; text-decoration: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }
.btn-accent { background: var(--accent); color: #000; }
.btn-accent:hover { background: var(--accent-light); }
.btn-outline { background: white; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: white; }
.btn-sm { padding: 5px 11px; font-size: .78rem; }
.btn-danger { background: var(--danger); color: white; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .8rem; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.form-control { width: 100%; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 8px; font-size: .84rem; color: var(--text); background: white; transition: border-color .15s; }
.form-control:focus { outline: none; border-color: var(--primary); }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
.form-check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.form-check input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }
.form-check label { font-size: .84rem; cursor: pointer; }

/* Password input with eye toggle */
.password-field-wrap { position: relative; }
.password-field-wrap .form-control { padding-right: 40px; }
.password-toggle-btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--muted);
  padding: 6px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
}
.password-toggle-btn:hover { color: var(--primary); background: #f1f5f9; }
.password-toggle-btn svg { width: 18px; height: 18px; }
.password-toggle-btn .icon-eye-off { display: none; }
.password-toggle-btn.revealed .icon-eye { display: none; }
.password-toggle-btn.revealed .icon-eye-off { display: block; }

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* Retention Score */
.retention-score { display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 52px; border-radius: 50%; font-size: 1rem; font-weight: 800; border: 3px solid; }
.retention-score.high { color: #16a34a; border-color: #16a34a; background: #dcfce7; }
.retention-score.mid { color: #d97706; border-color: #d97706; background: #fef3c7; }
.retention-score.low { color: #dc2626; border-color: #dc2626; background: #fee2e2; }

/* Week Progress */
.week-progress { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.week-dot { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .7rem; font-weight: 700; border: 2px solid; cursor: pointer; transition: all .15s; text-decoration: none; }
.week-dot.done { background: var(--success); border-color: var(--success); color: white; }
.week-dot.current { background: var(--accent); border-color: var(--accent); color: #000; }
.week-dot.pending { background: white; border-color: var(--border); color: var(--muted); }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 20px; overflow-x: auto; white-space: nowrap; }
.tab-btn { padding: 10px 20px; font-size: .84rem; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; background: none; border-top: none; border-left: none; border-right: none; transition: all .15s; }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Week Steps */
.week-steps { display: flex; gap: 0; margin-bottom: 24px; }
.week-step { flex: 1; text-align: center; position: relative; }
.week-step::after { content: ''; position: absolute; top: 18px; left: 50%; width: 100%; height: 2px; background: var(--border); z-index: 0; }
.week-step:last-child::after { display: none; }
.step-circle { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 700; margin: 0 auto 6px; position: relative; z-index: 1; border: 2px solid; text-decoration: none; }
.step-circle.done { background: var(--success); border-color: var(--success); color: white; }
.step-circle.active { background: var(--primary); border-color: var(--primary); color: white; }
.step-circle.pending { background: white; border-color: var(--border); color: var(--muted); }
.step-label { font-size: .7rem; font-weight: 600; color: var(--muted); }
.step-label.done { color: var(--success); }
.step-label.active { color: var(--primary); }

/* Messages/Chat */
.chat-layout { display: grid; grid-template-columns: 280px 1fr; height: calc(100vh - 140px); }
.chat-list { border-right: 1px solid var(--border); overflow-y: auto; position: relative; }
.chat-item { padding: 14px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .1s; display: flex; gap: 10px; align-items: center; text-decoration: none; color: inherit; }
.chat-item:hover { background: #f8fafc; }
.chat-item.active { background: #dbeafe; }
.chat-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--primary); color: white; display: flex; align-items: center; justify-content: center; font-size: .72rem; font-weight: 700; flex-shrink: 0; }
.chat-info { flex: 1; min-width: 0; }
.chat-name { font-size: .84rem; font-weight: 700; }
.chat-preview { font-size: .75rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-time { font-size: .7rem; color: var(--muted); }

.chat-window { display: flex; flex-direction: column; }
.chat-header { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 65%; }
.msg-bubble { padding: 10px 14px; border-radius: 12px; font-size: .84rem; line-height: 1.5; }
.msg.sent { align-self: flex-end; }
.msg.sent .msg-bubble { background: var(--primary); color: white; border-bottom-right-radius: 4px; }
.msg.recv .msg-bubble { background: #f1f5f9; color: var(--text); border-bottom-left-radius: 4px; }
.msg-time { font-size: .68rem; color: var(--muted); margin-top: 3px; }
.msg.sent .msg-time { text-align: right; }
.chat-input-area { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; }
.chat-input { flex: 1; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: 24px; font-size: .84rem; outline: none; }
.chat-input:focus { border-color: var(--primary); }
.chat-send-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--primary); color: white; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* Semantic Search */
.search-box-big { display: flex; gap: 10px; align-items: center; background: white; border: 2px solid var(--primary); border-radius: 14px; padding: 12px 16px; margin-bottom: 24px; }
.search-box-big input { flex: 1; border: none; outline: none; font-size: 1rem; color: var(--text); background: transparent; }
.search-result-item { background: white; border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 12px; }
.search-result-item h4 { font-size: .9rem; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.search-result-item p { font-size: .82rem; color: var(--muted); }

/* Profile section */
.sidebar-footer { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.1); display: flex; align-items: center; gap: 10px; }
.sidebar-footer .avatar { background: var(--accent); color: #000; font-size: .72rem; font-weight: 800; }
.sidebar-footer-info { flex: 1; min-width: 0; }
.sidebar-footer-name { font-size: .82rem; font-weight: 700; color: white; }
.sidebar-footer-role { font-size: .7rem; color: rgba(255,255,255,.5); }

/* Login Page */
.login-page { min-height: 100vh; display: flex; background: linear-gradient(135deg, #0f2347 0%, #1a3a6b 50%, #1e4480 100%); }
.login-left { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px; color: white; }
.login-right { width: 480px; background: white; display: flex; align-items: center; justify-content: center; padding: 60px; }
.login-form-wrap { width: 100%; max-width: 360px; }
.login-form-wrap h2 { font-size: 1.5rem; font-weight: 800; color: var(--primary); margin-bottom: 6px; }
.login-form-wrap p { font-size: .84rem; color: var(--muted); margin-bottom: 28px; }

/* Modals */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200; display: none; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: white; border-radius: 16px; width: 600px; max-width: 95vw; max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 1rem; font-weight: 800; }
.modal-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--muted); }
.modal-body { padding: 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: .84rem; display: flex; align-items: flex-start; gap: 8px; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* Progress bars */
.progress-bar-wrap { background: #e2e8f0; border-radius: 99px; height: 8px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--primary), var(--primary-light)); transition: width .5s; }
.progress-bar.gold { background: linear-gradient(90deg, #e8a020, #f5c060); }
.progress-bar.green { background: linear-gradient(90deg, #16a34a, #22c55e); }

/* Notification toast */
.toast-wrap { position: fixed; top: 70px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast { background: white; border-radius: 10px; padding: 12px 16px; box-shadow: 0 4px 20px rgba(0,0,0,.15); border-left: 4px solid var(--primary); max-width: 320px; font-size: .82rem; display: flex; align-items: flex-start; gap: 10px; animation: slideIn .3s ease; }
.toast-close { margin-left: auto; background: none; border: none; cursor: pointer; color: var(--muted); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Responsive */
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 99; }
.sidebar-backdrop.visible { display: block; }
#menu-btn { display: none; background: none; border: none; cursor: pointer; padding: 6px; color: var(--primary); flex-shrink: 0; }

@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }
  .sidebar { transform: translateX(-260px); box-shadow: none; transition: transform .28s ease, box-shadow .28s ease; z-index: 100; }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.22); }
  .main { margin-left: 0 !important; }
  .topbar { left: 0 !important; }
  #menu-btn { display: flex; align-items: center; justify-content: center; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .chat-layout { grid-template-columns: 1fr !important; }
  .chat-list { border-right: none; border-bottom: 1px solid var(--border); max-height: 220px; }
  .login-left { display: none; }
  .login-right { width: 100%; padding: 36px 24px; }
  .page { padding: 16px; }
  .card-body { padding: 14px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 560px; }
  .topbar { padding: 0 14px; }
  .topbar-title { font-size: .9rem; }
  .step-circle { width: 30px; height: 30px; font-size: .72rem; }
  .step-label { font-size: .62rem; }
  .week-dot { width: 24px; height: 24px; font-size: .62rem; }
  .modal { width: 96vw; margin: 10px; }
  .stat-value { font-size: 1.5rem; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 1.3rem; }
  .stat-label { font-size: .65rem; }
  .login-right { padding: 28px 18px; }
  .login-form-wrap h2 { font-size: 1.2rem; }
  .btn { padding: 7px 12px; font-size: .78rem; }
  .btn-sm { padding: 5px 9px; font-size: .72rem; }
  .card-header { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
  .card-title { font-size: .84rem; }
  .tabs { overflow-x: auto; white-space: nowrap; }
  .tab-btn { padding: 8px 14px; font-size: .78rem; }
}

@media (hover: none) {
  .nav-item:hover { background: none; }
  .nav-item.active { background: rgba(232,160,32,.15); }
  .btn:hover { opacity: .88; }
}

/* Utility */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }
.mb-6 { margin-bottom: 24px; }
.mt-4 { margin-top: 16px; }
.text-muted { color: var(--muted); }
.text-sm { font-size: .82rem; }
.fw-bold { font-weight: 700; }
.text-center { text-align: center; }
.w-full { width: 100%; }
.hidden { display: none; }
