/* ============================================================================
 * EcsFix Tool - Corporate Responsive Admin Panel Stylesheet
 * Clean Light Enterprise Surface • Desktop / Tablet / Mobile Responsive
 * ============================================================================ */
:root {
    --bg-page: #F8FAFC;
    --bg-surface: #FFFFFF;
    --bg-sidebar: #0B2545;
    --bg-sidebar-hover: rgba(255, 255, 255, 0.08);
    --bg-sidebar-active: #1D4ED8;
    --border: #E2E8F0;
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #64748B;
    --brand-primary: #1D4ED8;
    --brand-dark: #0F4C81;
    --brand-hover: #1E40AF;
    --success-bg: #DCFCE7;
    --success-txt: #15803D;
    --warning-bg: #FEF3C7;
    --warning-txt: #B45309;
    --danger-bg: #FEE2E2;
    --danger-txt: #B91C1C;
    --info-bg: #DBEAFE;
    --info-txt: #1D4ED8;
    --radius: 12px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.08);
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.5;
}

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

/* Layout Shell */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    color: #F8FAFC;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    transition: transform 0.2s ease;
}

.sidebar-brand {
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-shield {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, #1E88E5, #0F4C81);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
    color: #FFFFFF;
    flex-shrink: 0;
}

.sidebar-brand h1 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.sidebar-brand span {
    display: block;
    font-size: 11px;
    color: #93C5FD;
    margin-top: 2px;
}

.sidebar-nav {
    padding: 14px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-radius: 9px;
    color: #CBD5E1;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
    background: var(--bg-sidebar-hover);
    color: #FFFFFF;
    text-decoration: none;
}

.nav-link.active {
    background: var(--bg-sidebar-active);
    color: #FFFFFF;
    font-weight: 600;
}

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 12px;
    color: #94A3B8;
}

/* Main Content Area */
.main-area {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 20;
}

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

.mobile-menu-btn {
    display: none;
    background: #FFFFFF;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 11px;
    font-size: 16px;
    cursor: pointer;
}

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

.lang-switcher {
    display: inline-flex;
    background: #F1F5F9;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2px;
}

.lang-switcher a {
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
}

.lang-switcher a.active {
    background: #FFFFFF;
    color: var(--brand-primary);
    box-shadow: var(--shadow-sm);
}

.lang-switcher a:hover { text-decoration: none; }

.admin-pill {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 6px 10px;
    background: #F8FAFC;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.page-content {
    padding: 24px;
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
}

.page-header {
    margin-bottom: 20px;
}

.page-header h2 {
    margin: 0 0 4px 0;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

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

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.kpi-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    border-top: 4px solid var(--brand-primary);
}

.kpi-card.kpi-success { border-top-color: #16A34A; }
.kpi-card.kpi-warning { border-top-color: #D97706; }
.kpi-card.kpi-danger  { border-top-color: #DC2626; }
.kpi-card.kpi-info    { border-top-color: #2563EB; }

.kpi-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
}

.kpi-value {
    font-size: 30px;
    font-weight: 800;
    margin-top: 6px;
    color: var(--text-primary);
}

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

/* Cards & Grids */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    overflow: hidden;
}

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

.card-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
}

.card-body {
    padding: 20px;
}

.two-col {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 20px;
    align-items: start;
}

.two-col-equal {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.badge-success  { background: var(--success-bg); color: var(--success-txt); }
.badge-warning  { background: var(--warning-bg); color: var(--warning-txt); }
.badge-danger   { background: var(--danger-bg);  color: var(--danger-txt); }
.badge-info     { background: var(--info-bg);    color: var(--info-txt); }
.badge-neutral  { background: #F1F5F9; color: #334155; }

/* Tables */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th, td {
    padding: 11px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

th {
    background: #F8FAFC;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    white-space: nowrap;
}

tr:hover td {
    background: #F8FAFC;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
}

/* Forms & Buttons */
.form-group {
    margin-bottom: 14px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #CBD5E1;
    border-radius: 8px;
    font-size: 13px;
    background: #FFFFFF;
    color: var(--text-primary);
    font-family: inherit;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.checkbox-row input[type="checkbox"] {
    width: auto;
}

.checkbox-row label {
    margin: 0;
    font-weight: 500;
    color: var(--text-primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 15px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    text-decoration: none;
}

.btn:hover { text-decoration: none; }

.btn-primary {
    background: var(--brand-primary);
    color: #FFFFFF;
}
.btn-primary:hover { background: var(--brand-hover); }

.btn-secondary {
    background: #FFFFFF;
    color: var(--text-primary);
    border-color: #CBD5E1;
}
.btn-secondary:hover { background: #F8FAFC; }

.btn-success {
    background: #16A34A;
    color: #FFFFFF;
}
.btn-success:hover { background: #15803D; }

.btn-danger {
    background: #FEF2F2;
    color: #B91C1C;
    border-color: #FECACA;
}
.btn-danger:hover { background: #FEE2E2; }

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* Alerts */
.alert {
    padding: 12px 15px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.alert-success { background: #F0FDF4; color: #166534; border-color: #BBF7D0; }
.alert-error   { background: #FEF2F2; color: #991B1B; border-color: #FECACA; }
.alert-warning { background: #FFFBEB; color: #92400E; border-color: #FDE68A; }
.alert-info    { background: #EFF6FF; color: #1E40AF; border-color: #BFDBFE; }

/* Brand Progress Bars */
.brand-bar-row {
    margin-bottom: 14px;
}
.brand-bar-header {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 5px;
}
.brand-bar-track {
    height: 10px;
    background: #F1F5F9;
    border-radius: 999px;
    overflow: hidden;
}
.brand-bar-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #0F4C81, #2563EB);
}

/* QR Code Container */
.qr-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    background: #FFFFFF;
    border: 2px dashed #CBD5E1;
    border-radius: 12px;
    text-align: center;
}

.qr-stage canvas {
    max-width: 100%;
    height: auto;
    border: 12px solid #FFFFFF;
    box-shadow: var(--shadow-md);
    border-radius: 8px;
}

.code-chip {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 1px;
    background: #EFF6FF;
    color: #1E3A8A;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid #BFDBFE;
}

.pre-json {
    background: #0F172A;
    color: #E2E8F0;
    padding: 14px;
    border-radius: 8px;
    font-size: 11px;
    overflow-x: auto;
    max-height: 240px;
    margin: 0;
}

/* Login Page */
.login-page {
    min-height: 100vh;
    background: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #FFFFFF;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px;
    box-shadow: var(--shadow-md);
}

/* Modal */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 80;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop.open { display: flex; }

.modal-dialog {
    background: #FFFFFF;
    border-radius: 14px;
    max-width: 720px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-md);
}

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

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #0F172A;
    color: #FFFFFF;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--shadow-md);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 100;
}
.toast.show { opacity: 1; }

/* Responsive Breakpoints */
@media (max-width: 1024px) {
    .two-col, .two-col-equal {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 820px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-area {
        margin-left: 0;
    }
    .mobile-menu-btn {
        display: inline-flex;
    }
    .page-content {
        padding: 16px;
    }
}

@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .main-area { margin-left: 0 !important; }
    .card { border: none !important; box-shadow: none !important; }
}
