/**
 * Fatullah EnergyGuard - International Standard Design System & Core Stylesheet
 * High-performance, zero-dependency, fully responsive CSS architecture.
 */

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

/* ==========================================================================
   1. CSS Custom Properties / Design Tokens
   ========================================================================== */
:root {
    /* Brand & Accent Colors */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --primary-border: #bfdbfe;

    --success: #10b981;
    --success-hover: #059669;
    --success-light: #ecfdf5;
    --success-border: #a7f3d0;

    --warning: #f59e0b;
    --warning-hover: #d97706;
    --warning-light: #fffbeb;
    --warning-border: #fde68a;

    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-light: #fef2f2;
    --danger-border: #fecaca;

    --info: #06b6d4;
    --info-hover: #0891b2;
    --info-light: #ecfeff;
    --info-border: #a5f3fc;

    /* Neutrals & Surfaces */
    --bg-body: #f8fafc;
    --bg-surface: #ffffff;
    --bg-subtle: #f1f5f9;
    --border-color: #e2e8f0;
    --border-subtle: #f1f5f9;

    /* Text Colors */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --text-white: #ffffff;

    /* Layout & Navigation Dark Theme */
    --nav-bg: #0b132b;
    --nav-surface: #1c2541;
    --nav-border: #243256;
    --nav-text: #cbd5e1;
    --nav-text-hover: #ffffff;
    --nav-active-bg: rgba(37, 99, 235, 0.2);
    --nav-active-border: #3b82f6;

    /* Shadows */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.08), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

    /* Radii */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   2. Global Reset & Typography
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    overflow-x: hidden;
}

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

h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.25;
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

p {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

img, svg {
    display: inline-block;
    vertical-align: middle;
    max-width: 100%;
    height: auto;
}

/* ==========================================================================
   3. Top Navigation & Left Sidebar Layout
   ========================================================================== */
.eg-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 4rem;
    background: var(--nav-bg);
    border-bottom: 1px solid var(--nav-border);
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.25);
}

.eg-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
}
.eg-brand-logo {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #1e293b, #0f172a);
    padding: 0.25rem;
    box-shadow: 0 0 12px rgba(37, 99, 235, 0.4);
}
.eg-brand-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.eg-brand-badge {
    font-size: 0.65rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-full);
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.eg-sidebar {
    position: fixed;
    top: 4rem;
    left: 0;
    bottom: 0;
    width: 16.5rem;
    background: var(--nav-bg);
    border-right: 1px solid var(--nav-border);
    z-index: 35;
    overflow-y: auto;
    transition: transform var(--transition-normal);
    display: flex;
    flex-direction: column;
}

@media (max-width: 1023px) {
    .eg-sidebar {
        transform: translateX(-100%);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    }
    .eg-sidebar.is-open {
        transform: translateX(0);
    }
}

.eg-sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(11, 19, 43, 0.7);
    backdrop-filter: blur(4px);
    z-index: 30;
    display: none;
}
.eg-sidebar-overlay.is-open {
    display: block;
}

.eg-main-content {
    min-height: calc(100vh - 4rem);
    margin-top: 4rem;
    transition: margin var(--transition-normal);
}
@media (min-width: 1024px) {
    .eg-main-content {
        margin-left: 16.5rem;
    }
}

.eg-page-container {
    padding: 1.5rem;
    max-width: 1600px;
    margin: 0 auto;
}
@media (max-width: 640px) {
    .eg-page-container {
        padding: 1rem;
    }
}

/* Sidebar Navigation Items */
.eg-nav-group-title {
    font-size: 0.6875rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #64748b;
    padding: 1rem 1rem 0.35rem;
}
.eg-nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.85rem;
    margin: 0.15rem 0.5rem;
    border-radius: var(--radius-lg);
    color: var(--nav-text);
    font-weight: 500;
    font-size: 0.875rem;
    transition: all var(--transition-fast);
    cursor: pointer;
}
.eg-nav-item:hover {
    background: var(--nav-surface);
    color: var(--nav-text-hover);
    transform: translateX(2px);
}
.eg-nav-item.active {
    background: var(--nav-active-bg);
    color: #60a5fa;
    border-left: 3px solid var(--nav-active-border);
    font-weight: 600;
}
.eg-nav-icon {
    width: 1.25rem;
    font-size: 1rem;
    margin-right: 0.75rem;
    text-align: center;
    color: #94a3b8;
    transition: color var(--transition-fast);
}
.eg-nav-item:hover .eg-nav-icon,
.eg-nav-item.active .eg-nav-icon {
    color: #60a5fa;
}

.eg-submenu {
    list-style: none;
    padding: 0.25rem 0 0.5rem 2.5rem;
}
.eg-submenu a {
    display: block;
    padding: 0.4rem 0.75rem;
    font-size: 0.8125rem;
    color: #94a3b8;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}
.eg-submenu a:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.05);
}
.eg-submenu a.active {
    color: #60a5fa;
    background: rgba(37, 99, 235, 0.15);
    font-weight: 600;
}

/* ==========================================================================
   4. Universal Card Component
   ========================================================================== */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
    transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
    position: relative;
    overflow: hidden;
}
.card:hover {
    box-shadow: var(--shadow-md);
    border-color: #cbd5e1;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}
.card-header.bg-light {
    background: #f8fafc;
}
.card-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0;
}

.card-body {
    padding: 1.25rem;
}
.card-footer {
    padding: 0.875rem 1.25rem;
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
}

/* ==========================================================================
   5. International Standard Data Tables
   ========================================================================== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
}

.table {
    width: 100%;
    margin-bottom: 0;
    color: var(--text-primary);
    border-collapse: separate;
    border-spacing: 0;
    text-align: left;
}

.table th {
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.table td {
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    vertical-align: middle;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-surface);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table-hover tbody tr:hover td {
    background-color: #f8fafc;
    color: var(--text-primary);
}

.table-striped tbody tr:nth-of-type(odd) td {
    background-color: #fcfdfe;
}

.table-bordered {
    border: none;
}
.table-bordered th, 
.table-bordered td {
    border-right: 1px solid var(--border-subtle);
}
.table-bordered th:last-child, 
.table-bordered td:last-child {
    border-right: none;
}

/* ==========================================================================
   6. Modern Button System
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    font-weight: 500;
    font-size: 0.875rem;
    line-height: 1.25rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-xs);
    white-space: nowrap;
}
.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background-color: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}
.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #ffffff;
    box-shadow: var(--shadow-sm);
}

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

.btn-success {
    background-color: var(--success);
    color: #ffffff;
    border-color: var(--success);
}
.btn-success:hover {
    background-color: var(--success-hover);
    border-color: var(--success-hover);
    color: #ffffff;
}

.btn-danger {
    background-color: var(--danger);
    color: #ffffff;
    border-color: var(--danger);
}
.btn-danger:hover {
    background-color: var(--danger-hover);
    border-color: var(--danger-hover);
    color: #ffffff;
}

.btn-warning {
    background-color: var(--warning);
    color: #ffffff;
    border-color: var(--warning);
}
.btn-warning:hover {
    background-color: var(--warning-hover);
    border-color: var(--warning-hover);
    color: #ffffff;
}

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    border-radius: var(--radius-lg);
}

/* ==========================================================================
   7. Form Controls & Inputs
   ========================================================================== */
.form-label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control, .form-select {
    display: block;
    width: 100%;
    padding: 0.55rem 0.85rem;
    font-size: 0.875rem;
    font-family: inherit;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    outline: none;
}
.form-control::placeholder {
    color: #94a3b8;
}

/* ==========================================================================
   8. Badges, Indicators & Alerts
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    border-radius: var(--radius-full);
}
.bg-primary { background-color: var(--primary-light) !important; color: var(--primary) !important; border: 1px solid var(--primary-border); }
.bg-success { background-color: var(--success-light) !important; color: #047857 !important; border: 1px solid var(--success-border); }
.bg-warning { background-color: var(--warning-light) !important; color: #b45309 !important; border: 1px solid var(--warning-border); }
.bg-danger { background-color: var(--danger-light) !important; color: #b91c1c !important; border: 1px solid var(--danger-border); }
.bg-info { background-color: var(--info-light) !important; color: #0e7490 !important; border: 1px solid var(--info-border); }

.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-lg);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
}
.alert-success { background: var(--success-light); color: #065f46; border: 1px solid var(--success-border); }
.alert-danger { background: var(--danger-light); color: #991b1b; border: 1px solid var(--danger-border); }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid var(--warning-border); }

/* ==========================================================================
   9. Grid & Flexbox Utilities (Compatible with both Tailwind & Bootstrap markup)
   ========================================================================== */
.container, .container-fluid {
    width: 100%;
    margin-right: auto;
    margin-left: auto;
}
.container {
    max-width: 1440px;
    padding: 0 1rem;
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -0.75rem;
    margin-left: -0.75rem;
}
.row > * {
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    padding-right: 0.75rem;
    padding-left: 0.75rem;
}

.col-12 { flex: 0 0 100%; max-width: 100%; }
.col-auto { flex: 0 0 auto; width: auto; }

@media (min-width: 768px) {
    .col-md-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
    .col-md-3 { flex: 0 0 25%; max-width: 25%; }
    .col-md-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
    .col-md-6 { flex: 0 0 50%; max-width: 50%; }
    .col-md-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
    .col-md-12 { flex: 0 0 100%; max-width: 100%; }
}

@media (min-width: 1024px) {
    .col-lg-3 { flex: 0 0 25%; max-width: 25%; }
    .col-lg-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
    .col-lg-6 { flex: 0 0 50%; max-width: 50%; }
}

/* Tailwind Grid Emulation */
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

@media (max-width: 767px) {
    .grid-cols-2, .grid-cols-3, .grid-cols-4, .grid-cols-6 {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }
}
@media (min-width: 768px) and (max-width: 1023px) {
    .grid-cols-3, .grid-cols-4, .grid-cols-6 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }

/* Flexbox Utilities */
.d-flex, .flex { display: flex; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center, .align-items-center { align-items: center; }
.align-items-end { align-items: flex-end; }
.justify-between, .justify-content-between { justify-content: space-between; }
.justify-center, .justify-content-center { justify-content: center; }
.flex-1 { flex: 1 1 0%; }
.flex-fill { flex: 1 1 auto; }

/* Spacing Utilities */
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.25rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.25rem; }
.mt-6 { margin-top: 1.5rem; }
.mr-1 { margin-right: 0.25rem; }
.mr-2 { margin-right: 0.5rem; }
.mr-3 { margin-right: 0.75rem; }
.ml-1 { margin-left: 0.25rem; }
.ml-2 { margin-left: 0.5rem; }
.mx-2 { margin-left: 0.5rem; margin-right: 0.5rem; }
.mx-auto { margin-left: auto; margin-right: auto; }

.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }

/* Rounding & Shadows */
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

/* Text Utilities */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-base { font-size: 1rem; line-height: 1.5rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.text-white { color: #ffffff; }
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted { color: var(--text-muted) !important; }

/* Pulse animation */
@keyframes pulseGlow {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.95); }
}
.animate-pulse {
    animation: pulseGlow 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Custom modern scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
