/* ============================================
   NutriTrack - Main Stylesheet
   HiQ Milk Distribution Management System
   ============================================ */

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

:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-card-hover: #253349;
    --bg-input: #0f172a;
    --border-color: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #06b6d4;
    --accent-hover: #22d3ee;
    --accent-glow: rgba(6, 182, 212, 0.3);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.15);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.15);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.15);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.15);
    --sidebar-width: 260px;
    --header-height: 65px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -2px rgba(0,0,0,0.2);
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.4);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Noto Sans Lao', 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

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

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== LOGIN PAGE ===== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1a1a2e 50%, #16213e 100%);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.login-wrapper::before {
    content: '';
    position: absolute;
    width: 500px; height: 500px;
    background: radial-gradient(circle, var(--accent-glow), transparent 70%);
    top: -100px; right: -100px;
    animation: float 8s ease-in-out infinite;
}

.login-wrapper::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.15), transparent 70%);
    bottom: -100px; left: -100px;
    animation: float 10s ease-in-out infinite reverse;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(30px, -30px) scale(1.1); }
}

.login-box {
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 50px 40px;
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 35px;
}

.login-logo .logo-icon {
    width: 70px; height: 70px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin-bottom: 15px;
    box-shadow: 0 8px 25px var(--accent-glow);
}

.login-logo h1 {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-logo p { color: var(--text-secondary); font-size: 14px; margin-top: 5px; }

/* ===== FORM ELEMENTS ===== */
.form-group { margin-bottom: 20px; }

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea.form-control { resize: vertical; min-height: 80px; }

/* Hide number input spinners */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] { -moz-appearance: textbox; appearance: textbox; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #0284c7);
    color: white;
    box-shadow: 0 4px 15px var(--accent-glow);
}
.btn-primary:hover { box-shadow: 0 6px 20px var(--accent-glow); color: white; }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; color: white; }

.btn-warning { background: var(--warning); color: #1e293b; }
.btn-warning:hover { background: #d97706; color: #1e293b; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; color: white; }

.btn-secondary { background: var(--border-color); color: var(--text-primary); }
.btn-secondary:hover { background: var(--text-muted); }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-block { width: 100%; justify-content: center; }

/* ===== LAYOUT ===== */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    border-right: 1px solid var(--border-color);
    z-index: 100;
    overflow-y: auto;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.sidebar-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 99;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}
.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

.sidebar-brand {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-brand .brand-icon {
    width: 42px; height: 42px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.sidebar-brand h2 {
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-brand small { display: block; color: var(--text-muted); font-size: 11px; font-weight: 400; }

.sidebar-menu { padding: 15px 0; }

.menu-label {
    padding: 10px 20px 5px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: var(--text-secondary);
    font-size: 14px;
    transition: var(--transition);
    border-left: 3px solid transparent;
    margin: 2px 0;
}

.menu-item:hover {
    background: rgba(6, 182, 212, 0.08);
    color: var(--text-primary);
    border-left-color: var(--accent);
}

.menu-item.active {
    background: rgba(6, 182, 212, 0.12);
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 500;
}

.menu-item .icon { width: 20px; text-align: center; font-size: 16px; }

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: var(--transition);
}

.top-bar {
    height: var(--header-height);
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.top-bar .page-title { font-size: 18px; font-weight: 600; }

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.user-avatar {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.content-area { padding: 30px; }

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.card-header h3 { font-size: 16px; font-weight: 600; }
.card-body { padding: 24px; }
.card-footer {
    padding: 15px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 100px; height: 100px;
    border-radius: 50%;
    opacity: 0.05;
    transform: translate(30px, -30px);
}

.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.stat-card .stat-icon {
    width: 52px; height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.stat-card .stat-icon.cyan { background: rgba(6, 182, 212, 0.15); color: var(--accent); }
.stat-card .stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-card .stat-icon.amber { background: var(--warning-bg); color: var(--warning); }
.stat-card .stat-icon.red { background: var(--danger-bg); color: var(--danger); }
.stat-card .stat-icon.blue { background: var(--info-bg); color: var(--info); }

.stat-card .stat-info h4 { font-size: 13px; color: var(--text-secondary); font-weight: 400; margin-bottom: 5px; }
.stat-card .stat-info .stat-value { font-size: 26px; font-weight: 700; }
.stat-card .stat-info .stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ===== TABLE ===== */
.table-responsive { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    padding: 14px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.5);
    vertical-align: middle;
    white-space: nowrap;
}

.data-table tbody tr { transition: var(--transition); }
.data-table tbody tr:hover { background: rgba(6, 182, 212, 0.04); }

.data-table .actions { display: flex; gap: 6px; }

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-secondary { background: rgba(100, 116, 139, 0.15); color: var(--text-muted); }

/* ===== ALERTS ===== */
.alert {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.3); }
.alert-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.3); }
.alert-info { background: var(--info-bg); color: var(--info); border: 1px solid rgba(59, 130, 246, 0.3); }

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: var(--transition);
}

.modal-overlay.active .modal { transform: scale(1); }

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 { font-size: 16px; }

.modal-close {
    width: 32px; height: 32px;
    border: none; background: var(--bg-primary);
    color: var(--text-secondary);
    border-radius: 8px; cursor: pointer;
    font-size: 18px; transition: var(--transition);
}
.modal-close:hover { background: var(--danger-bg); color: var(--danger); }

.modal-body { padding: 24px; }
.modal-footer { padding: 15px 24px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 10px; }

/* ===== FILTER BAR ===== */
.filter-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar .form-control { max-width: 220px; padding: 9px 14px; font-size: 13px; }

/* ===== PAGINATION ===== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
    list-style: none;
}

.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px; height: 36px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    transition: var(--transition);
}

.pagination a { background: var(--bg-primary); border: 1px solid var(--border-color); color: var(--text-secondary); }
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .active { background: var(--accent); color: white; border: 1px solid var(--accent); }

/* ===== GRID HELPERS ===== */
.row { display: flex; flex-wrap: wrap; margin: 0 -10px; }
.col-3 { width: 25%; padding: 0 10px; }
.col-4 { width: 33.333%; padding: 0 10px; }
.col-6 { width: 50%; padding: 0 10px; }
.col-12 { width: 100%; padding: 0 10px; }

/* ===== CUSTOMER TYPE BADGE ===== */
.type-hospital { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.type-clinic { background: rgba(6, 182, 212, 0.15); color: #06b6d4; }
.type-health_center { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.type-pharmacy { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }
.type-other { background: rgba(100, 116, 139, 0.15); color: #64748b; }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 15px; }
.empty-state h4 { font-size: 16px; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 14px; margin-bottom: 20px; }

/* ===== MOBILE TOGGLE ===== */
.mobile-toggle {
    display: none;
    background: none; border: none; color: var(--text-primary);
    font-size: 24px; cursor: pointer; padding: 5px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .mobile-toggle { display: block; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .col-3, .col-4, .col-6 { width: 100%; }
    .content-area { padding: 20px 15px; }
    .filter-bar .form-control { max-width: 100%; flex: 1; }
    .top-bar { padding: 0 15px; }
    .user-info > div:not(.user-avatar) { display: none; }
    .user-info { padding: 2px; background: transparent; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .login-box { padding: 35px 25px; }
}

/* ===== NOTIFICATION BELL ===== */
.notif-badge {
    position: absolute; top: 2px; right: 2px;
    background: var(--danger); color: white;
    font-size: 10px; font-weight: 700;
    min-width: 18px; height: 18px;
    border-radius: 10px; display: flex;
    align-items: center; justify-content: center;
    padding: 0 4px; line-height: 1;
    animation: bellPulse 2s ease-in-out infinite;
}
@keyframes bellPulse {
    0%,100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}
.notif-bell:hover { color: var(--accent) !important; }

.notif-dropdown {
    position: absolute; top: 100%; right: 0;
    width: 340px; max-height: 420px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 300; overflow: hidden;
    opacity: 0; visibility: hidden;
    transform: translateY(8px) scale(0.96);
    transition: all 0.2s ease;
}
.notif-dropdown.show {
    opacity: 1; visibility: visible;
    transform: translateY(0) scale(1);
}
.notif-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex; justify-content: space-between;
    align-items: center; font-size: 14px;
}
.notif-list { max-height: 340px; overflow-y: auto; }
.notif-item {
    display: flex; gap: 12px; padding: 12px 16px;
    border-bottom: 1px solid rgba(51,65,85,0.3);
    transition: var(--transition); cursor: default;
}
.notif-item:hover { background: rgba(6,182,212,0.04); }
.notif-item.unread { background: rgba(6,182,212,0.08); border-left: 3px solid var(--accent); }
.notif-icon {
    width: 36px; height: 36px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; flex-shrink: 0;
}
.notif-icon.amber { background: var(--warning-bg); color: var(--warning); }
.notif-icon.red { background: var(--danger-bg); color: var(--danger); }
.notif-icon.blue { background: var(--info-bg); color: var(--info); }
.notif-msg { font-size: 13px; line-height: 1.4; }
.notif-time { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.notif-empty { text-align: center; padding: 30px; color: var(--text-muted); font-size: 13px; }
