/* =========================================
   1. FONTS & RESET
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap');

:root {
    --font-family: 'Poppins', sans-serif;
    --color-brand: #123c69;
    --color-brand-strong: #0f3154;
    --color-brand-soft: #eaf1f8;
    --color-accent: #b88a2f;
    --color-accent-strong: #8a6116;
    --color-accent-soft: #fff8e6;
    --color-canvas: #f6f7f9;
    --color-surface: #ffffff;
    --color-text: #1f2937;
    --color-muted: #667085;
    --color-border: #e4e7ec;
    --color-danger: #b42318;
    --color-danger-soft: #fef3f2;
    --color-success: #067647;
    --color-success-soft: #ecfdf3;
    --color-warning: #b54708;
    --color-warning-soft: #fffaeb;
    --color-info: #175cd3;
    --color-info-soft: #eff8ff;
    --radius-card: 16px;
    --shadow-card: 0 8px 24px rgba(15, 23, 42, 0.06);
    --focus-ring: 0 0 0 3px rgba(18, 60, 105, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-family);
}

body {
    background-color: var(--color-canvas);
    color: var(--color-text);
    min-height: 100vh;
}

.login-page {
    overflow-x: hidden;
}

/* =========================================
   2. LOGIN PAGE STYLES
   ========================================= */
.login-wrapper {
    background: linear-gradient(135deg, var(--color-brand) 0%, var(--color-brand-strong) 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 48px;
}

.login-box {
    background: rgba(255, 255, 255, 0.95);
    padding: 68px 54px;
    border-radius: 15px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    width: min(100%, 400px);
    text-align: center;
}

.login-logo {
    display: block;
    width: auto;
    height: 80px;
    max-width: min(100%, 150px);
    margin: 0 auto 20px;
}

.login-box h2 { color: var(--color-text); margin-bottom: 5px; }
.login-box p { color: var(--color-muted); font-size: 14px; margin-bottom: 30px; }

.input-group { margin-bottom: 20px; text-align: left; }
.input-group label { display: block; color: #475467; font-size: 13px; margin-bottom: 5px; }

input[type="text"], input[type="password"], input[type="number"], select {
    width: 100%;
    padding: 12px;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    outline: none;
    transition: 0.3s;
}

input:focus, select:focus {
    border-color: var(--color-brand);
    box-shadow: var(--focus-ring);
}

:focus-visible {
    outline: 3px solid rgba(18, 60, 105, 0.55);
    outline-offset: 2px;
}

button.btn-login {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, var(--color-brand), var(--color-brand-strong));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}
button.btn-login:hover { transform: scale(1.02); }

.error-msg {
    background-color: var(--color-danger-soft);
    color: var(--color-danger);
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 20px;
    font-size: 13px;
    word-break: break-word;
}

@media (max-width: 640px) {
    .login-wrapper {
        padding: 30px 22px;
        align-items: stretch;
    }

    .login-box {
        margin: auto;
        padding: 50px 32px 40px;
        border-radius: 18px;
    }

    .login-logo {
        height: 68px;
        margin-bottom: 16px;
    }

    .login-box h2 {
        font-size: 28px;
    }

    .login-box p {
        margin-bottom: 22px;
    }

    .input-group {
        margin-bottom: 16px;
    }

    input[type="text"],
    input[type="password"],
    input[type="number"],
    select,
    button.btn-login {
        min-height: 48px;
    }
}

@media (max-width: 380px) {
    .login-wrapper {
        padding: 20px;
    }

    .login-box {
        padding: 38px 24px 30px;
    }

    .login-box h2 {
        font-size: 24px;
    }

    .login-box p,
    .input-group label,
    .error-msg {
        font-size: 12px;
    }
}

/* =========================================
   3. DASHBOARD LAYOUT (SIDEBAR + MAIN)
   ========================================= */
.dashboard-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
    height: calc(100vh - 80px);
    overflow: hidden;
}

/* SIDEBAR */
.sidebar {
    width: 260px;
    background: var(--color-brand);
    color: white;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-shadow: 4px 0 10px rgba(0,0,0,0.1);
    transition: width 0.3s ease;
    flex-shrink: 0; /* Prevent shrinking */
    position: sticky;
    top: 0;
    height: 100%;
    align-self: flex-start;
}

/* SIDEBAR HEADER (Fixed) */
.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    margin-bottom: 30px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    height: 50px;
}

.sidebar h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    white-space: nowrap; /* Keep text on one line */
    overflow: hidden;    /* Hide if too long */
}

.toggle-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
}

/* MENU LINKS */
.sidebar a {
    text-decoration: none;
    color: rgba(255,255,255,0.8);
    padding: 15px;
    margin-bottom: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    transition: 0.3s;
    white-space: nowrap;
    overflow: hidden;
    position: relative;
}

.sidebar a i {
    width: 25px; /* Fixed icon width for alignment */
    text-align: center;
    margin-right: 10px;
}

/* MENU LINKS HOVER EFFECT */
.sidebar a:hover, .sidebar a.active {
    background: rgba(255,255,255,0.15); /* Light transparent background */
    color: white;
    transform: translateX(5px); /* This makes it POP to the right */
    box-shadow: 2px 2px 5px rgba(0,0,0,0.2); /* Slight shadow for 3D effect */
}

.notif-dot {
    width: 8px;
    height: 8px;
    background: #b42318;
    border-radius: 50%;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
}

/* MAIN CONTENT AREA */
.main-content {
    flex: 1; /* Take remaining width */
    padding: 40px; /* Space inside the grey area */
    background: var(--color-canvas);
    overflow-y: auto; /* Allow scrolling */
    height: 100%;
}

.header-title {
    font-size: 26px;
    color: #333;
    margin-bottom: 30px;
    font-weight: 600;
}

/* =========================================
   4. COLLAPSED SIDEBAR STATE
   ========================================= */
.sidebar.collapsed {
    width: 80px;
}

.sidebar.collapsed h3, 
.sidebar.collapsed a span {
    display: none; /* Hide text */
}

.sidebar.collapsed .sidebar-header {
    justify-content: center; /* Center hamburger icon */
}

.sidebar.collapsed a {
    justify-content: center; /* Center icons */
}

.sidebar.collapsed a i {
    margin-right: 0; /* Remove gap */
}

/* 
   5. STATS CARDS
    */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 5px solid var(--color-brand);
    transition: transform 0.3s, box-shadow 0.3s;
}

.card-link { text-decoration: none; color: inherit; display: block; }
.card-link:hover .stat-card,
.stat-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.12);
}

.stat-info h4 { color: #888; font-size: 14px; margin-bottom: 5px; }
.stat-info p { color: #333; font-size: 28px; font-weight: 700; margin: 0; }
.low-stock-name { font-size: 13px; color: #b42318; font-weight: 600; margin-top: 5px; height: 20px; }

/* 
   6. TABLES & FORMS
    */
.table-container {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}

/* =========================================
   6. TABLES & FORMS (FIXED ANIMATION)
   ========================================= */
.table-container {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}

.styled-table { width: 100%; border-collapse: collapse; margin-top: 15px; }

.styled-table th { 
    background-color: var(--color-brand);
    color: white; 
    text-align: left; 
    padding: 12px 15px; 
}

.styled-table td { 
    padding: 12px 15px; 
    border-bottom: 1px solid #dddddd; 
}

/* THE ANIMATION MAGIC */
.styled-table tbody tr {
    transition: all 0.2s ease; /* Smooth transition */
    cursor: pointer;
}

.styled-table tbody tr:hover { 
    background-color: #f3f3f3; 
    transform: scale(1.01); /* The "Pop" effect */
    box-shadow: 0 5px 15px rgba(0,0,0,0.1); /* Subtle shadow on hover */
    z-index: 10; /* Bring to front */
    position: relative; /* Needed for z-index */
}

.amount-badge { font-weight: bold; color: var(--color-success); }

/* FORM BUTTON */
.btn-submit {
    width: 100%;
    padding: 15px;
    background: linear-gradient(to right, var(--color-brand), var(--color-brand-strong));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
}
.btn-submit:hover { transform: scale(1.02); }

/* =========================================
   7. LOADER (GLASS EFFECT)
   ========================================= */
#loader-wrapper {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 99999;
    display: flex; justify-content: center; align-items: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loader-logo { width: 80px; animation: spin 1.5s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.loader-hidden { opacity: 0; visibility: hidden; pointer-events: none; }


















/* =========================================
   8. RESPONSIVE (MOBILE)
   ========================================= */
@media (max-width: 768px) {
    .dashboard-container {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        padding: 10px 12px;
        display: block;
    }

    .sidebar-header {
        border-bottom: none;
        margin-bottom: 8px;
        padding-bottom: 0;
        width: auto;
    }

    .sidebar a {
        display: inline-flex;
        width: auto;
        margin: 0 6px 8px 0;
        padding: 10px 12px;
        transform: none !important;
        box-shadow: none !important;
    }

    .sidebar.collapsed {
        width: 100%;
    }
    .sidebar.collapsed h3,
    .sidebar.collapsed a span {
        display: inline;
    }

    .main-content { padding: 20px; height: auto; overflow-y: visible; }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .styled-table {
        min-width: 700px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
