/* ============================================================
   FuelGuard — app.css
   ระบบควบคุมน้ำมันเชื้อเพลิง เทศบาลนคร สกลนคร
   ไม่พึ่ง CDN ทำงานได้ Offline
   ============================================================ */

/* --- Google Fonts (ถ้า Host ไม่มี internet ตัด 2 บรรทัดนี้ออก) --- */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&display=swap');

/* --- CSS Variables --- */
:root {
    --primary:       #1a56db;
    --primary-dark:  #1341a8;
    --primary-light: #e8f0fe;
    --success:       #057a55;
    --success-light: #def7ec;
    --danger:        #c81e1e;
    --danger-light:  #fde8e8;
    --warning:       #c27803;
    --warning-light: #fdf6b2;
    --info:          #0369a1;
    --info-light:    #e0f2fe;

    --gray-50:  #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    --white: #ffffff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow:    0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
    --shadow-xl: 0 20px 25px rgba(0,0,0,.1), 0 10px 10px rgba(0,0,0,.04);

    --radius-sm: 6px;
    --radius:    8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl:24px;

    --font: 'Sarabun', 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'Courier New', monospace;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    color: var(--gray-800);
    background: var(--gray-50);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
input, button, select, textarea { font-family: var(--font); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, #0f2952 0%, #1a4a7a 50%, #1e6b4a 100%);
    position: relative;
    overflow: hidden;
}
.login-page::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: rgba(255,255,255,.03);
    border-radius: 50%;
    top: -200px; right: -100px;
}
.login-page::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: rgba(255,255,255,.03);
    border-radius: 50%;
    bottom: -150px; left: -100px;
}
.login-box {
    width: 100%;
    max-width: 400px;
    position: relative;
    z-index: 1;
}
.login-header { text-align: center; margin-bottom: 2rem; }
.login-icon { font-size: 3.5rem; margin-bottom: .75rem; }
.login-title { font-size: 1.75rem; font-weight: 700; color: #fff; margin-bottom: .25rem; }
.login-subtitle { font-size: .9rem; color: rgba(255,255,255,.7); }
.login-org { font-size: .8rem; color: rgba(255,255,255,.5); margin-top: .25rem; }

.login-card {
    background: var(--white);
    border-radius: var(--radius-2xl);
    padding: 2rem;
    box-shadow: var(--shadow-xl);
}
.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: .75rem;
    color: rgba(255,255,255,.4);
}

/* ============================================================
   LAYOUT — Sidebar + Content
   ============================================================ */
.app-wrapper { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 260px;
    background: #0f2952;
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform .3s ease;
}
.sidebar-brand {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
    display: flex;
    align-items: center;
    gap: .75rem;
}
.sidebar-brand-icon { font-size: 1.75rem; }
.sidebar-brand-name { font-size: 1.1rem; font-weight: 700; }
.sidebar-brand-sub  { font-size: .7rem; color: rgba(255,255,255,.5); }

.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; }
.nav-section-title {
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .08em;
    color: rgba(255,255,255,.4);
    padding: .75rem 1.5rem .25rem;
    text-transform: uppercase;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem 1.5rem;
    color: rgba(255,255,255,.75);
    font-size: .9rem;
    cursor: pointer;
    transition: all .2s;
    border-left: 3px solid transparent;
    text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-item.active {
    background: rgba(255,255,255,.12);
    color: #fff;
    border-left-color: #60a5fa;
    font-weight: 600;
}
.nav-icon { font-size: 1.1rem; width: 1.5rem; text-align: center; }
.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    padding: .1rem .4rem;
    border-radius: 999px;
    min-width: 1.2rem;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,.1);
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: .75rem;
}
.sidebar-avatar {
    width: 36px; height: 36px;
    background: rgba(255,255,255,.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
    flex-shrink: 0;
}
.sidebar-user-name  { font-size: .85rem; font-weight: 600; color: #fff; }
.sidebar-user-role  { font-size: .72rem; color: rgba(255,255,255,.5); }

/* Main Content */
.main-content {
    margin-left: 260px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: .875rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}
.topbar-title { font-size: 1.1rem; font-weight: 600; color: var(--gray-800); }
.topbar-right { display: flex; align-items: center; gap: 1rem; }

.page-content { padding: 1.5rem; flex: 1; }

/* ============================================================
   COMPONENTS
   ============================================================ */

/* --- Form --- */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block;
    font-size: .875rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: .4rem;
}
.form-label .required { color: var(--danger); margin-left: .2rem; }
.form-control {
    width: 100%;
    padding: .6rem .875rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: .9rem;
    font-family: var(--font);
    color: var(--gray-800);
    background: var(--white);
    transition: border-color .2s, box-shadow .2s;
    line-height: 1.5;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,.15);
}
.form-control::placeholder { color: var(--gray-400); }
.form-control:disabled { background: var(--gray-100); cursor: not-allowed; }
.form-control.is-invalid { border-color: var(--danger); }
.form-error { font-size: .8rem; color: var(--danger); margin-top: .3rem; }
.form-hint  { font-size: .8rem; color: var(--gray-500); margin-top: .3rem; }

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

.input-group { position: relative; }
.input-group .form-control { padding-right: 2.5rem; }
.input-group-btn {
    position: absolute;
    right: .5rem; top: 50%;
    transform: translateY(-50%);
    background: none; border: none;
    cursor: pointer; font-size: 1rem;
    color: var(--gray-400); padding: .25rem;
}
.input-group-btn:hover { color: var(--gray-600); }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .6rem 1.25rem;
    border-radius: var(--radius);
    font-size: .9rem;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all .2s;
    white-space: nowrap;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary   { background: var(--primary);   color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success   { background: var(--success);   color: #fff; }
.btn-success:hover { background: #046044; }
.btn-danger    { background: var(--danger);    color: #fff; }
.btn-danger:hover  { background: #a81a1a; }
.btn-warning   { background: var(--warning);   color: #fff; }
.btn-secondary { background: var(--gray-100);  color: var(--gray-700); border-color: var(--gray-300); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-outline   { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary-light); }

.btn-sm { padding: .4rem .875rem; font-size: .82rem; }
.btn-lg { padding: .8rem 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { padding: .5rem; border-radius: var(--radius); }

/* --- Cards --- */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--gray-50);
}
.card-title { font-size: 1rem; font-weight: 600; color: var(--gray-800); }
.card-body   { padding: 1.25rem; }
.card-footer {
    padding: .875rem 1.25rem;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

/* --- Stats Cards (Dashboard) --- */
.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}
.stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}
.stat-icon.blue    { background: var(--primary-light); }
.stat-icon.green   { background: var(--success-light); }
.stat-icon.red     { background: var(--danger-light);  }
.stat-icon.yellow  { background: var(--warning-light); }
.stat-label { font-size: .8rem; color: var(--gray-500); margin-bottom: .2rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--gray-800); line-height: 1.2; }
.stat-sub   { font-size: .78rem; color: var(--gray-500); margin-top: .2rem; }

/* --- Alerts / Notifications --- */
.alert {
    padding: .875rem 1rem;
    border-radius: var(--radius);
    font-size: .9rem;
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}
.alert-success { background: var(--success-light); color: #065f46; border-color: #a7f3d0; }
.alert-danger  { background: var(--danger-light);  color: #9b1c1c; border-color: #fca5a5; }
.alert-warning { background: var(--warning-light); color: #92400e; border-color: #fcd34d; }
.alert-info    { background: var(--info-light);    color: #075985; border-color: #7dd3fc; }

/* --- Badge --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger  { background: var(--danger-light);  color: var(--danger);  }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-gray    { background: var(--gray-100);      color: var(--gray-600);}

/* --- Table --- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--gray-200); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead { background: var(--gray-50); }
th {
    padding: .75rem 1rem;
    text-align: left;
    font-size: .78rem;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}
td {
    padding: .75rem 1rem;
    color: var(--gray-700);
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }

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

/* --- Utilities --- */
.text-center { text-align: center; }
.text-right  { text-align: right;  }
.text-muted  { color: var(--gray-500); }
.text-small  { font-size: .82rem; }
.text-danger { color: var(--danger); }
.text-success{ color: var(--success);}
.fw-bold     { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.d-flex { display: flex; align-items: center; }
.gap-1  { gap: .5rem; }
.gap-2  { gap: 1rem;  }
.justify-between { justify-content: space-between; }
.w-100  { width: 100%; }

/* --- OTP Input --- */
.otp-input {
    width: 100%;
    padding: 1rem;
    font-size: 2rem;
    text-align: center;
    letter-spacing: .5rem;
    font-family: var(--font-mono);
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-lg);
    transition: border-color .2s;
}
.otp-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,.15);
}

/* --- Mobile Responsive --- */
.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--gray-600);
    padding: .25rem;
}
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 99;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.open { display: block; }
    .main-content { margin-left: 0; }
    .hamburger   { display: block; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .page-content { padding: 1rem; }
    .topbar { padding: .75rem 1rem; }
    .hide-mobile { display: none; }
}

@media (max-width: 480px) {
    .login-card { padding: 1.5rem; }
    .stat-value { font-size: 1.3rem; }
}
