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

:root {
    --bg-main: #f3f6f9;
    --bg-card: #ffffff;
    --bg-input: #f8fafc;

    --border-color: #e2e8f0;
    --border-focus: #3b82f6;

    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-inverse: #ffffff;

    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: #eff6ff;
    --primary-glow: rgba(59, 130, 246, 0.15);

    --secondary: #0f172a;
    --secondary-hover: #1e293b;

    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
}

body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-main);
    color: var(--text-main);
}

.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ========= Sidebar ========= */
.sidebar {
    width: 280px;
    background-color: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    box-sizing: border-box;
    box-shadow: 2px 0 10px rgba(0,0,0,0.02);
    z-index: 20;
}

.sidebar-brand {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 2.5rem;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1;
}

.nav-item {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.nav-item:hover {
    background: var(--bg-main);
    color: var(--text-main);
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

/* Sidebar Account Profile */
.sidebar-footer {
    margin-top: auto;
    padding: 1.25rem 0 0 0;
    border-top: 1px solid var(--border-color);
}
.am-header {
    text-align: center;
    margin-bottom: 1rem;
}
.am-avatar-large {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #e2e8f0;
    border: 2px solid var(--primary);
    margin-bottom: 0.5rem;
    padding: 2px;
}
.am-name {
    margin: 0 0 0.2rem 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
}
.am-handle {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}
.am-details {
    background: var(--bg-main);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
}
.am-row {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0;
    border-bottom: 1px dashed var(--border-color);
}
.am-row:last-child { border-bottom: none; }
.am-label {
    color: var(--text-muted);
    font-size: 0.8rem;
}
.am-val {
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.82rem;
    text-align: right;
    max-width: 60%;
    word-break: break-word;
}
.am-actions { display: flex; gap: 0.75rem; }
.btn-am-logout {
    flex: 1;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--danger);
    padding: 0.55rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    font-size: 0.85rem;
    text-align: center;
    text-decoration: none;
    display: block;
}
.btn-am-logout:hover {
    background: #fee2e2;
}

/* ========= Main Content ========= */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.topbar {
    height: 64px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.breadcrumbs {
    font-size: 0.9rem;
    color: var(--text-muted);
}
.breadcrumbs span {
    color: var(--text-main);
    font-weight: 600;
}

.btn-logout-outline {
    text-decoration: none;
    color: var(--danger);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    transition: 0.2s;
}
.btn-logout-outline:hover {
    background-color: rgba(239, 68, 68, 0.05);
    border-color: var(--danger);
}

.dashboard-body {
    padding: 2rem 2.5rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

/* ========= Metrics ========= */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
    transition: 0.2s;
}
.metric-card:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.04);
    transform: translateY(-2px);
}

.metric-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.75rem;
    line-height: 1.4;
}
.metric-title span {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

.metric-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
}
.metric-value small {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* ========= Section Cards ========= */
.section-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
    transition: 0.2s;
}
.section-card:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.04);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.section-header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}
.section-header h3::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 18px;
    background: var(--primary);
    border-radius: 4px;
}

.status-dot {
    font-size: 0.8rem;
    color: var(--success);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}
.status-dot::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
}

/* ========= Forms ========= */
.info-grid {
    display: grid;
    gap: 1.25rem 1.5rem;
}
.info-grid.three-cols { grid-template-columns: repeat(3, 1fr); }
.info-grid.two-cols { grid-template-columns: repeat(2, 1fr); }

.form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.required-star {
    color: #ef4444;
    margin-left: 2px;
}

.fancy-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-input);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    box-sizing: border-box;
    transition: 0.2s;
    outline: none;
}
.fancy-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: #fff;
}
.fancy-input[readonly] {
    background: #f1f5f9;
    color: var(--text-muted);
    cursor: default;
}

/* ========= Stream Table ========= */
.stream-table {
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.stream-header {
    display: flex;
    gap: 1.5rem;
    background: #f8fafc;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    border-radius: 12px 12px 0 0;
}

.stream-row, .stream-total-row {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    transition: 0.2s;
}
.stream-row:hover {
    background: var(--primary-light);
}
.stream-row:last-child { border-bottom: none; }
.stream-total-row {
    background: #f8fafc;
    border-bottom: none;
    border-top: 2px solid var(--border-color);
}

.col-l { width: 25%; display: flex; flex-direction: column; gap: 5px; }
.col-c { flex: 1; display: flex; align-items: center; gap: 8px; }
.col-r { width: 25%; }
.col-x { width: 5%; text-align: right; }

.font-bold { font-weight: 700; color: var(--text-main); font-size: 1rem; }

/* ========= Custom Select ========= */
.row-label {
    font-size: 0.85rem;
    color: var(--text-main);
    font-weight: 600;
}
.custom-select-wrapper {
    position: relative;
    width: fit-content;
    user-select: none;
}
.custom-select-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 20px;
    border: 1px solid #cbd5e1;
    background: #fff;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    color: var(--text-main);
    transition: 0.2s;
    min-width: 100px;
}
.custom-select-btn:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}
.custom-select-btn i {
    font-size: 0.65rem;
    font-style: normal;
    color: var(--text-muted);
}
.custom-select-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 120px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    padding: 4px;
    display: none;
    z-index: 999;
    border: 1px solid var(--border-color);
}
.custom-select-menu.show { display: block; }
.custom-select-option {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--text-main);
    border-radius: 8px;
    transition: 0.15s;
    margin-bottom: 2px;
}
.custom-select-option:last-child { margin-bottom: 0; }
.custom-select-option:hover {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 500;
}

.stream-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
}

.hint-text {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.btn-outline-small {
    background: #fff;
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-main);
    transition: 0.2s;
}
.btn-outline-small:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-remove {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.4;
    transition: 0.2s;
}
.btn-remove:hover { opacity: 1; }

.total-input {
    font-weight: 700;
    color: var(--primary);
    background: transparent !important;
    border: none;
    padding: 0;
}

/* ========= Summary Dashboard ========= */
.summary-dashboard {
    background: var(--primary-light);
    border: 1px solid var(--border-focus);
    border-radius: 16px;
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.summary-cards {
    display: flex;
    gap: 3rem;
}

.summary-item {
    display: flex;
    flex-direction: column;
}
.summary-item .lbl {
    font-size: 0.85rem;
    color: var(--primary);
    margin-bottom: 0.3rem;
    font-weight: 600;
}
.summary-item .val {
    font-size: 1.6rem;
    color: var(--primary-hover);
    font-weight: 800;
}

.btn-large {
    padding: 0.85rem 2rem;
    font-size: 1rem;
}

/* ========= Dashboard Grid ========= */
.dashboard-grid {
    display: flex;
    gap: 1.75rem;
    align-items: flex-start;
}
.dashboard-main-col {
    flex: 1;
    min-width: 0;
}
.dashboard-side-col {
    width: 380px;
    position: sticky;
    top: 88px;
}

/* ========= Report Box ========= */
.report-container {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    align-items: stretch;
}

.report-box {
    flex: 1;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    padding: 1.25rem;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-main);
}

.report-title {
    font-weight: 700;
    color: var(--text-muted);
    margin: 0 0 1rem 0;
    font-size: 0.85rem;
}

.report-box p { margin: 0.25rem 0; }

.report-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 200px;
}

/* ========= Buttons ========= */
.btn-primary-solid {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.85rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: 0.2s;
    box-shadow: 0 4px 12px var(--primary-glow);
}
.btn-primary-solid:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px var(--primary-glow);
}

.btn-dark-solid {
    background: var(--secondary);
    color: white;
    border: none;
    padding: 0.85rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: 0.2s;
}
.btn-dark-solid:hover {
    background: var(--secondary-hover);
    transform: translateY(-1px);
}

/* ========= Login Page ========= */
.login-body {
    background: linear-gradient(135deg, #e0eafc 0%, #cfdef3 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
}

.login-container {
    background: #ffffff;
    padding: 3rem 2.5rem;
    border-radius: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
}

.login-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.login-icon-box {
    width: 56px;
    height: 56px;
    background-color: var(--primary);
    border-radius: 16px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    color: white;
    margin-bottom: 1rem;
    box-shadow: 0 8px 16px var(--primary-glow);
}

.login-header h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    margin: 0 0 0.5rem 0;
}

.login-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}

.login-container .form-group {
    margin-bottom: 1.5rem;
}

.login-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.login-input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    box-sizing: border-box;
    outline: none;
    border-radius: 12px;
    transition: 0.2s;
}
.login-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: #fff;
}

.input-with-icon { position: relative; }

.toggle-password {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}
.toggle-password:hover { color: #64748b; }
.input-with-icon .login-input { padding-right: 44px; }

.btn-login-submit {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: 0.2s;
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px var(--primary-glow);
}
.btn-login-submit:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #fff;
    border-bottom-color: transparent;
    border-radius: 50%;
    display: inline-block;
    animation: rotation 1s linear infinite;
}
@keyframes rotation {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-msg {
    background-color: #fef2f2;
    color: var(--danger);
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid #fecaca;
    text-align: center;
}

/* ========= SweetAlert ========= */
div:where(.swal2-container) div:where(.swal2-popup) {
    border-radius: 20px !important;
    width: 320px !important;
    padding: 1.5rem !important;
    font-family: inherit !important;
}
div:where(.swal2-container) h2:where(.swal2-title) {
    font-size: 1.2rem !important;
}

/* ========= History Page ========= */
.table-input-readonly {
    text-align: center;
}

/* ========= Responsive & Mobile UI ========= */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-main);
    cursor: pointer;
    padding: 0;
}

@media (max-width: 1024px) {
    /* Topbar & Sidebar */
    .mobile-menu-btn {
        display: block;
    }
    
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        transition: left 0.3s ease;
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .dashboard-body {
        padding: 1.5rem;
    }

    /* Grids */
    .dashboard-grid {
        flex-direction: column;
    }
    
    .dashboard-side-col {
        width: 100%;
        position: static;
    }
    
    .metric-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    /* Metric & Form Grids */
    .metric-grid {
        grid-template-columns: 1fr;
    }
    
    .info-grid.three-cols, .info-grid.two-cols {
        grid-template-columns: 1fr;
    }
    
    /* Summary Dashboard */
    .summary-dashboard {
        flex-direction: column;
        align-items: stretch;
        gap: 1.5rem;
    }
    
    .summary-cards {
        flex-direction: column;
        gap: 1rem;
    }
    
    .summary-dashboard .btn-large {
        width: 100%;
    }
    
    /* Stream Table (Stack cols) */
    .stream-header {
        display: none; /* Hide header on mobile, stack rows instead */
    }
    
    .stream-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        background: #fff;
        border: 1px solid var(--border-color);
        border-radius: 10px;
        margin-bottom: 1rem;
        padding: 1.25rem;
    }
    
    .stream-row .col-l, .stream-row .col-c, .stream-row .col-r {
        width: 100%;
        max-width: 100%;
    }
    
    .stream-row .col-x {
        width: 100%;
        text-align: right;
    }
    
    .stream-total-row {
        flex-direction: column;
        gap: 1rem;
    }
}
