/* ============================================================
   SEO Management System — Mobile-First Design System
   Design: Data-Dense Dashboard (UI-UX Pro Max)
   ============================================================ */

/* --- Design Tokens --- */
:root {
    --primary: #7C3AED;
    --primary-light: #A78BFA;
    --primary-dark: #5B21B6;
    --primary-50: #F5F3FF;
    --primary-100: #EDE9FE;
    --primary-200: #DDD6FE;
    --accent: #F97316;
    --accent-light: #FB923C;
    --bg: #FAF5FF;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F5F3FF;
    --text: #4C1D95;
    --text-secondary: #6D28D9;
    --text-muted: #7C7C9A;
    --border: #E9E5F5;
    --border-focus: #A78BFA;
    --success: #059669;
    --success-bg: #ECFDF5;
    --danger: #DC2626;
    --danger-bg: #FEF2F2;
    --warning-bg: #FFF7ED;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-full: 9999px;
    --shadow-sm: 0 1px 3px rgba(124, 58, 237, 0.08);
    --shadow: 0 4px 12px rgba(124, 58, 237, 0.1);
    --shadow-lg: 0 8px 30px rgba(124, 58, 237, 0.15);
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Noto Sans Thai', 'Noto Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --navbar-h: 60px;
    --bottom-nav-h: 68px;
    --sidebar-w: 240px;
}

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

/* --- Base --- */
html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

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

/* --- Motion --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-h);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
    box-shadow: 0 2px 16px rgba(124, 58, 237, 0.25);
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.navbar-brand {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
    white-space: nowrap;
}

.hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255,255,255,0.15);
    border-radius: var(--radius-sm);
    color: #fff;
    cursor: pointer;
    transition: background var(--transition);
}
.hamburger:hover { background: rgba(255,255,255,0.25); }

.navbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-user-info {
    display: none;
}

.navbar-name {
    font-size: 14px;
    font-weight: 500;
}

.role-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    background: rgba(255,255,255,0.2);
    color: #fff;
    backdrop-filter: blur(4px);
    white-space: nowrap;
}

.navbar-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.8);
    transition: all var(--transition);
    cursor: pointer;
}
.navbar-action:hover {
    color: #fff;
    background: rgba(255,255,255,0.15);
}
.navbar-action svg { width: 20px; height: 20px; }

/* ============================================================
   SIDEBAR (Desktop + Mobile Drawer)
   ============================================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 199;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.open { display: block; }

.sidebar {
    position: fixed;
    top: var(--navbar-h);
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 16px 12px;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform var(--transition);
    overflow-y: auto;
}
.sidebar.open { transform: translateX(0); }

.sidebar-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    cursor: pointer;
}
.sidebar-link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}
.sidebar-link:hover {
    background: var(--primary-50);
    color: var(--primary);
}
.sidebar-link.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

/* ============================================================
   BOTTOM NAV (Mobile only)
   ============================================================ */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-h);
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -2px 12px rgba(124, 58, 237, 0.08);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex: 1;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 500;
    transition: color var(--transition);
    cursor: pointer;
    padding: 6px 2px;
    text-align: center;
    line-height: 1.2;
}
.bottom-nav-item svg {
    width: 22px;
    height: 22px;
}
.bottom-nav-item.active {
    color: var(--primary);
    font-weight: 700;
}
.bottom-nav-item:hover { color: var(--primary); }

/* ============================================================
   LAYOUT
   ============================================================ */
.layout {
    display: flex;
    min-height: calc(100vh - var(--navbar-h));
    min-height: calc(100dvh - var(--navbar-h));
    margin-top: var(--navbar-h);
}

.main-content {
    flex: 1;
    padding: 16px;
    padding-bottom: calc(var(--bottom-nav-h) + 16px);
    width: 100%;
    max-width: 100%;
}

/* ============================================================
   AUTH PAGES (Login)
   ============================================================ */
body.auth-page {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    min-height: 100vh;
    min-height: 100dvh;
}

.login-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    padding: 32px 24px;
}

.login-header {
    text-align: center;
    margin-bottom: 28px;
}

.login-header h1 {
    color: var(--text);
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 6px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 14px;
}

.login-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}
.login-btn:hover {
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.4);
    transform: translateY(-1px);
}
.login-btn:active { transform: translateY(0); }

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: box-shadow var(--transition);
}

.card h2 {
    color: var(--text);
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.card h2 svg { width: 22px; height: 22px; color: var(--primary); }

/* ============================================================
   STATS GRID
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.stat-box {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    padding: 16px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-box h3 {
    font-size: 11px;
    font-weight: 500;
    margin-bottom: 6px;
    opacity: 0.85;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-box .value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 15px;
    color: var(--text);
    background: var(--bg-card);
    transition: border-color var(--transition), box-shadow var(--transition);
    min-height: 48px;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.15);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

/* Custom SELECT — hide native arrow */
.form-group select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237C3AED' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
    padding-right: 42px;
    cursor: pointer;
}

/* Custom Dropdown (JS-powered replacement for native select) */
.custom-select {
    position: relative;
}

.custom-select-trigger {
    width: 100%;
    padding: 12px 42px 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 15px;
    color: var(--text);
    background: var(--bg-card);
    cursor: pointer;
    display: flex;
    align-items: center;
    min-height: 48px;
    transition: border-color var(--transition), box-shadow var(--transition);
    position: relative;
    user-select: none;
}
.custom-select-trigger::after {
    content: '';
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237C3AED' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
    transition: transform var(--transition);
}
.custom-select.open .custom-select-trigger {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
}
.custom-select.open .custom-select-trigger::after {
    transform: translateY(-50%) rotate(180deg);
}

.custom-select-options {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 500;
    max-height: 200px;
    overflow-y: auto;
    display: none;
    animation: scaleIn 0.15s ease;
}
.custom-select.open .custom-select-options {
    display: block;
}

.custom-select-option {
    padding: 12px 14px;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}
.custom-select-option:hover {
    background: var(--primary-50);
    color: var(--primary);
}
.custom-select-option.selected {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}
.custom-select-option:first-child {
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.custom-select-option:last-child {
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

/* Custom FILE INPUT — hide native, show styled button */
.form-group input[type="file"] {
    padding: 0;
    border: 2px dashed var(--border);
    background: var(--primary-50);
    min-height: 56px;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}
.form-group input[type="file"]:hover {
    border-color: var(--primary-light);
    background: var(--primary-100);
}
.form-group input[type="file"]::file-selector-button {
    padding: 10px 18px;
    margin-right: 12px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition);
}
.form-group input[type="file"]::file-selector-button:hover {
    background: var(--primary-dark);
}

/* Custom DATE INPUT */
.form-group input[type="date"] {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237C3AED' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
    padding-right: 42px;
    cursor: pointer;
}
.form-group input[type="date"]::-webkit-calendar-picker-indicator {
    opacity: 0;
    width: 42px;
    height: 100%;
    position: absolute;
    right: 0;
    cursor: pointer;
}

/* Custom NUMBER INPUT — hide native spinners */
.form-group input[type="number"] {
    -moz-appearance: textfield;
}
.form-group input[type="number"]::-webkit-outer-spin-button,
.form-group input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 20px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    min-height: 44px;
}
.btn svg { width: 18px; height: 18px; }
.btn:hover {
    background: var(--primary-dark);
    color: #fff;
    box-shadow: var(--shadow);
}
.btn:active { transform: scale(0.98); }

.btn-secondary {
    background: var(--primary-100);
    color: var(--primary);
}
.btn-secondary:hover {
    background: var(--primary-200);
    color: var(--primary-dark);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover {
    background: #B91C1C;
    color: #fff;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 13px;
    min-height: 36px;
}

.btn-assess {
    background: var(--success);
}
.btn-assess:hover { background: #047857; }

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-sm);
}

/* ============================================================
   ALERTS
   ============================================================ */
.error-message {
    background: var(--danger-bg);
    color: var(--danger);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
    border-left: 4px solid var(--danger);
}

.success-message {
    background: var(--success-bg);
    color: var(--success);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
    border-left: 4px solid var(--success);
}

.demo-info {
    background: var(--primary-50);
    padding: 16px;
    border-radius: var(--radius-sm);
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-secondary);
    border-left: 4px solid var(--primary);
}
.demo-info h3 {
    color: var(--primary);
    margin-bottom: 8px;
    font-size: 14px;
}
.demo-info p { margin-bottom: 4px; }

/* ============================================================
   TABLES (Desktop) + Cards (Mobile)
   ============================================================ */
.responsive-table {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

table thead { display: none; }

table tr {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    padding: 14px;
    transition: box-shadow var(--transition);
}
table tr:hover { box-shadow: var(--shadow-sm); }

table td {
    padding: 4px 0;
    font-size: 14px;
    color: var(--text);
    border: none;
}
table td::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 2px;
}

table th {
    font-weight: 600;
    color: var(--text);
    font-size: 13px;
}

/* ============================================================
   BADGES
   ============================================================ */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
}

.status-pending {
    background: var(--warning-bg);
    color: var(--accent);
}

.status-assessed {
    background: var(--success-bg);
    color: var(--success);
}

/* ============================================================
   ASSESSMENT & DETAIL BOXES
   ============================================================ */
.assess-form {
    background: var(--primary-50);
    padding: 16px;
    border-radius: var(--radius-sm);
    margin-top: 12px;
    display: none;
    border: 1px solid var(--primary-100);
}
.assess-form.show { display: block; }

.detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.detail-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.detail-value {
    font-size: 15px;
    color: var(--text);
    font-weight: 500;
}

.assessment-box {
    background: var(--success-bg);
    padding: 16px;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--success);
    margin-top: 16px;
}

.kpi-box {
    background: var(--primary-50);
    padding: 16px;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--primary);
    margin-top: 12px;
}

.score-cell {
    font-weight: 700;
    color: var(--primary);
    font-size: 16px;
}

/* ============================================================
   KPI BAR
   ============================================================ */
.kpi-bar {
    background: var(--primary-100);
    border-radius: var(--radius-full);
    height: 20px;
    position: relative;
    overflow: hidden;
}
.kpi-bar-fill {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================
   LISTS
   ============================================================ */
.attachments-list,
.links-list {
    list-style: none;
    padding: 0;
}
.attachments-list li,
.links-list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}
.attachments-list li:last-child,
.links-list li:last-child { border-bottom: none; }
.attachments-list a,
.links-list a {
    color: var(--primary);
    font-weight: 500;
    word-break: break-all;
}
.attachments-list a:hover,
.links-list a:hover { color: var(--primary-dark); }

/* ============================================================
   ADD FORM (Manage Users)
   ============================================================ */
.add-form {
    background: var(--primary-50);
    padding: 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    display: none;
    border: 1px solid var(--primary-100);
}
.add-form.show { display: block; }

/* ============================================================
   LINK GROUP
   ============================================================ */
.link-group {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}
.link-group input { flex: 1; }

/* ============================================================
   DATE RANGE / PICKER
   ============================================================ */
.date-range,
.date-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.date-range label,
.date-picker label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}
.date-range input[type="date"],
.date-picker input[type="date"] {
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    min-height: 44px;
    transition: border-color var(--transition);
    appearance: none;
    -webkit-appearance: none;
    background-color: var(--bg-card);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237C3AED' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-right: 36px;
    cursor: pointer;
    position: relative;
}
.date-range input[type="date"]::-webkit-calendar-picker-indicator,
.date-picker input[type="date"]::-webkit-calendar-picker-indicator {
    opacity: 0;
    width: 36px;
    height: 100%;
    position: absolute;
    right: 0;
    cursor: pointer;
}
.date-range input[type="date"]:focus,
.date-picker input[type="date"]:focus {
    outline: none;
    border-color: var(--border-focus);
}

/* ============================================================
   BACK LINK
   ============================================================ */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
    color: var(--primary);
    font-size: 14px;
    font-weight: 500;
    transition: color var(--transition);
}
.back-link:hover { color: var(--primary-dark); }
.back-link svg { width: 18px; height: 18px; }

/* ============================================================
   ACTION BAR
   ============================================================ */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    gap: 12px;
    flex-wrap: wrap;
}

/* ============================================================
   RESPONSIVE — Tablet (≥ 768px)
   ============================================================ */
@media (min-width: 768px) {
    .hamburger { display: none; }

    .navbar { padding: 0 24px; }
    .navbar-brand { font-size: 20px; }

    .navbar-user-info {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .sidebar {
        transform: translateX(0);
        position: fixed;
        box-shadow: none;
    }

    .bottom-nav { display: none; }

    .main-content {
        margin-left: var(--sidebar-w);
        padding: 24px;
        padding-bottom: 24px;
    }

    .form-row {
        flex-direction: row;
        gap: 16px;
    }
    .form-row .form-group { flex: 1; }

    /* Table desktop mode */
    table thead {
        display: table-header-group;
    }
    table thead tr {
        display: table-row;
        background: var(--primary-50);
        border: none;
        margin-bottom: 0;
        padding: 0;
        border-radius: 0;
    }

    table tbody tr {
        display: table-row;
        border: none;
        border-radius: 0;
        margin-bottom: 0;
        padding: 0;
    }
    table tbody tr:hover {
        background: var(--bg-card-hover);
        box-shadow: none;
    }

    table th, table td {
        padding: 14px 16px;
        text-align: left;
        border-bottom: 1px solid var(--border);
        font-size: 14px;
        color: #1E0A3C;
    }
    table th {
        color: var(--primary-dark);
        font-weight: 700;
        font-size: 13px;
        text-transform: uppercase;
        letter-spacing: 0.3px;
    }
    table td::before { display: none; }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 16px;
    }

    .detail-grid {
        grid-template-columns: 140px 1fr;
        gap: 8px 20px;
    }

    .card {
        padding: 24px;
        box-shadow: var(--shadow);
        border: 1px solid var(--border);
    }
    .card h2 { font-size: 20px; }

    table {
        box-shadow: var(--shadow-sm);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        overflow: hidden;
    }
    table thead tr {
        background: var(--primary-100);
    }
    table th {
        color: var(--text);
        font-weight: 700;
    }
    table tbody tr:nth-child(even) {
        background: var(--primary-50);
    }

    .add-form .form-row {
        flex-direction: row;
    }
}

/* ============================================================
   RESPONSIVE — Desktop (≥ 1024px)
   ============================================================ */
@media (min-width: 1024px) {
    .main-content {
        padding: 32px;
        max-width: calc(100vw - var(--sidebar-w));
    }

    .login-container {
        padding: 40px;
    }

    .stat-box .value { font-size: 32px; }
}

/* ============================================================
   RESPONSIVE — Wide (≥ 1440px)
   ============================================================ */
@media (min-width: 1440px) {
    .main-content {
        max-width: 1400px;
        padding: 36px 48px;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }

    .card {
        padding: 28px;
    }
}

/* ============================================================
   RESPONSIVE — Ultra Wide (≥ 1920px)
   ============================================================ */
@media (min-width: 1920px) {
    .main-content {
        max-width: 1600px;
        padding: 40px 56px;
    }
}

/* ============================================================
   ANIMATIONS — Card Entrance
   ============================================================ */
@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.card, .stat-box, .login-container {
    animation: fadeSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.card:nth-child(2) { animation-delay: 0.08s; }
.card:nth-child(3) { animation-delay: 0.16s; }
.card:nth-child(4) { animation-delay: 0.24s; }

.stat-box:nth-child(1) { animation-delay: 0.05s; }
.stat-box:nth-child(2) { animation-delay: 0.1s; }
.stat-box:nth-child(3) { animation-delay: 0.15s; }

/* ============================================================
   RIPPLE EFFECT — Buttons
   ============================================================ */
.btn, .login-btn, .bottom-nav-item, .sidebar-link {
    position: relative;
    overflow: hidden;
}

.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    transform: scale(0);
    animation: rippleAnim 0.6s ease-out;
    pointer-events: none;
}

@keyframes rippleAnim {
    to { transform: scale(4); opacity: 0; }
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
    position: fixed;
    top: calc(var(--navbar-h) + 12px);
    right: 12px;
    left: 12px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
    pointer-events: auto;
    cursor: pointer;
    backdrop-filter: blur(8px);
}

.toast--success {
    background: rgba(5, 150, 105, 0.95);
    color: #fff;
}
.toast--error {
    background: rgba(220, 38, 38, 0.95);
    color: #fff;
}
.toast--info {
    background: rgba(124, 58, 237, 0.95);
    color: #fff;
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: rgba(255,255,255,0.4);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    animation: toastProgress 4s linear both;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-12px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(-12px) scale(0.96); }
}

@keyframes toastProgress {
    from { width: 100%; }
    to { width: 0%; }
}

@media (min-width: 768px) {
    .toast-container {
        left: auto;
        width: 380px;
    }
}

/* ============================================================
   PASSWORD TOGGLE
   ============================================================ */
.password-wrapper {
    position: relative;
}
.password-wrapper input {
    padding-right: 48px;
}
.password-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: color var(--transition);
}
.password-toggle:hover { color: var(--primary); }

/* ============================================================
   FORM LOADING STATE
   ============================================================ */
.btn.loading {
    pointer-events: none;
    opacity: 0.7;
    position: relative;
}
.btn.loading::after {
    content: '';
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   FORM INPUT FOCUS ANIMATION
   ============================================================ */
.form-group {
    position: relative;
}

.form-group input:not([type="file"]):focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
    transform: translateY(-1px);
}

/* ============================================================
   CUSTOM CONFIRM DIALOG
   ============================================================ */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: fadeIn 0.2s ease;
}

.confirm-dialog {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 28px 24px;
    max-width: 360px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
}

.confirm-dialog h3 {
    font-size: 18px;
    color: var(--text);
    margin-bottom: 8px;
}

.confirm-dialog p {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.confirm-actions .btn {
    flex: 1;
    max-width: 140px;
}

/* ============================================================
   COUNTER ANIMATION (stat values)
   ============================================================ */
.stat-box .value {
    transition: transform 0.3s ease;
}
.stat-box:hover .value {
    transform: scale(1.05);
}

/* ============================================================
   TABLE ROW HOVER (Mobile card)
   ============================================================ */
table tr {
    transition: transform var(--transition), box-shadow var(--transition);
}

@media (max-width: 767px) {
    table tr:active {
        transform: scale(0.98);
    }
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.4;
}
.empty-state p {
    font-size: 15px;
}
