/* ==========================================================================
   Admin Dashboard Stylesheet - Thai Gov Portal
   ========================================================================== */

:root {
    --primary: #1e3a8a;
    --primary-light: #3b82f6;
    --primary-dark: #0f172a;
    --secondary: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-active: #2563eb;
    --border-color: #e2e8f0;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 15px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: all 0.3s ease;
    z-index: 100;
}

.sidebar-brand {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    text-decoration: none;
    color: #fff;
}

.sidebar-brand img {
    width: 38px;
    height: 38px;
    object-fit: contain;
}

.sidebar-brand h2 {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}

.sidebar-brand span {
    font-size: 12px;
    color: #94a3b8;
    display: block;
}

.sidebar-menu {
    list-style: none;
    padding: 15px 10px;
    flex: 1;
    overflow-y: auto;
}

.menu-header {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
    padding: 12px 15px 6px;
    letter-spacing: 0.5px;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 15px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    margin-bottom: 3px;
}

.sidebar-menu li a i {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.sidebar-menu li a:hover {
    color: #fff;
    background: rgba(255,255,255,0.06);
}

.sidebar-menu li a.active {
    color: #fff;
    background: var(--sidebar-active);
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}

.menu-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 700;
}

/* Main Content Area */
.admin-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Topbar */
.admin-topbar {
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 90;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.topbar-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-dark);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    padding: 5px 10px;
    border-radius: 8px;
    transition: background 0.2s;
}

.user-profile-badge:hover {
    background: var(--bg-body);
}

.user-avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #eff6ff;
    color: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    border: 1px solid #bfdbfe;
}

.user-info {
    text-align: left;
}

.user-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    display: block;
}

.user-role-label {
    font-size: 11px;
    color: var(--text-muted);
}

/* Content Container */
.admin-content {
    padding: 30px;
    flex: 1;
}

/* Alerts */
.alert {
    padding: 14px 18px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    position: relative;
}

.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-close { margin-left: auto; background: none; border: none; font-size: 20px; cursor: pointer; color: inherit; opacity: 0.7; }

/* Dashboard Metric Cards */
/* Dashboard Metric Cards & Grids */
.metrics-grid, .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.metric-card, .stat-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 22px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 18px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover, .stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.metric-icon, .stat-icon {
    width: 54px;
    height: 54px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.metric-icon.blue, .stat-icon.icon-blue { background: #eff6ff; color: #2563eb; }
.metric-icon.green, .stat-icon.icon-green { background: #ecfdf5; color: #10b981; }
.metric-icon.amber, .metric-icon.orange, .stat-icon.icon-orange { background: #fffbeb; color: #f59e0b; }
.metric-icon.red, .stat-icon.icon-red { background: #fef2f2; color: #ef4444; }
.metric-icon.purple, .stat-icon.icon-purple { background: #faf5ff; color: #8b5cf6; }

.metric-info, .stat-info {
    display: flex;
    flex-direction: column;
}

.metric-info .label, .stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 4px;
}

.metric-info .value, .stat-number {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

/* Card Boxes */
.card-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 25px;
    overflow: hidden;
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-body {
    padding: 24px;
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.data-table, .admin-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th, .admin-table th {
    background: #f8fafc;
    color: var(--text-muted);
    font-size: 12.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table td, .admin-table td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13.5px;
    vertical-align: middle;
}

.data-table tbody tr:hover, .admin-table tbody tr:hover {
    background: #f8fafc;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-pending { background: #fef3c7; color: #92400e; }
.badge-in_progress { background: #e0f2fe; color: #0369a1; }
.badge-resolved { background: #dcfce7; color: #15803d; }
.badge-closed { background: #f1f5f9; color: #475569; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-primary { background: var(--primary-light); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-outline { background: #fff; color: var(--text-main); border: 1px solid var(--border-color); }
.btn-outline:hover { background: #f1f5f9; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

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

.data-table th {
    background: #f8fafc;
    padding: 12px 18px;
    font-size: 12.5px;
    font-weight: 700;
    color: #475569;
    border-bottom: 2px solid var(--border-color);
    text-transform: uppercase;
}

.data-table td {
    padding: 14px 18px;
    font-size: 13.5px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.data-table tr:hover {
    background: #f8fafc;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11.5px;
    font-weight: 600;
}

.badge-active, .badge-published, .badge-open, .badge-resolved { background: #dcfce7; color: #166534; }
.badge-inactive, .badge-closed, .badge-draft { background: #fee2e2; color: #991b1b; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-in_progress { background: #e0e7ff; color: #3730a3; }

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: #334155;
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    outline: none;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 650px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
}

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

.modal-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--primary-dark);
}

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: #f8fafc;
}

/* Responsive */
@media (max-width: 768px) {
    .admin-sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        z-index: 1000;
        box-shadow: 5px 0 25px rgba(0,0,0,0.3);
    }
    .admin-sidebar.open {
        left: 0;
    }
    .form-grid-2, .form-grid-3, .dashboard-grid {
        grid-template-columns: 1fr !important;
    }
    .admin-topbar {
        padding: 10px 15px;
    }
    .admin-content {
        padding: 15px;
    }
}

/* ==========================================================================
   Login Page Styles
   ========================================================================== */
.login-page {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #0f172a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    top: -30%;
    right: -20%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.15) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.login-page::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -20%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(245, 158, 11, 0.1) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.login-card {
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
    width: 100%;
    max-width: 440px;
    padding: 40px 35px;
    position: relative;
    z-index: 10;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

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

.login-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin: 0 auto 16px;
    display: block;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.login-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: #1e3a8a;
    margin-bottom: 6px;
}

.login-header p {
    font-size: 13px;
    color: #64748b;
    font-weight: 400;
}

.login-card .form-group {
    margin-bottom: 20px;
}

.login-card .form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 8px;
}

.login-card .form-control {
    width: 100%;
    height: 46px;
    padding: 10px 16px 10px 42px;
    font-size: 14px;
    border: 1.5px solid #cbd5e1;
    border-radius: 10px;
    background-color: #f8fafc;
    color: #1e293b;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.login-card .form-control:focus {
    background-color: #ffffff;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    outline: none;
}

.btn-block {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 48px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    background-color: #2563eb;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-block:hover {
    background-color: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex !important;
}

.modal-box {
    background: #ffffff;
    border-radius: 16px;
    width: 100%;
    max-width: 650px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    animation: modalFadeIn 0.2s ease-out;
}

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