/* ============================================
   PREMIUM BLUE & WHITE THEME
   ============================================ */

:root {
    --primary:        #1e3a8a;
    --primary-dark:   #172554;
    --primary-light:  #3b82f6;
    --primary-soft:   #eff6ff;
    --accent:         #60a5fa;
    --white:          #ffffff;
    --text:           #1f2937;
    --text-light:     #6b7280;
    --border:         #e5e7eb;
    --danger:         #dc2626;
    --danger-soft:    #fee2e2;
    --success:        #16a34a;
    --success-soft:   #dcfce7;
    --bg:             #f5f7fb;
    --shadow-sm:      0 1px 3px rgba(0,0,0,0.06);
    --shadow:         0 4px 16px rgba(30, 58, 138, 0.08);
    --shadow-lg:      0 12px 40px rgba(30, 58, 138, 0.15);
    --radius:         10px;
    --radius-sm:      6px;
    --transition:     0.25s ease;
}

* {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

html, body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    max-width: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    -webkit-text-size-adjust: 100%;
    min-height: 100vh;
    line-height: 1.5;
}

/* ============================================
   MOBILE TOPBAR (hidden on desktop)
   ============================================ */
.mobile-topbar {
    display: none;
    position: sticky;
    top: 0;
    z-index: 900;
    background: var(--primary);
    color: var(--white);
    padding: 12px 16px;
    align-items: center;
    gap: 14px;
    box-shadow: 0 2px 12px rgba(30, 58, 138, 0.25);
}

.mobile-brand {
    font-weight: 600;
    font-size: 16px;
    letter-spacing: 0.3px;
}

.hamburger {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.12);
    border: none;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 0;
    transition: background var(--transition);
}

.hamburger:active {
    background: rgba(255, 255, 255, 0.25);
}

.hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--white);
    border-radius: 2px;
    transition: var(--transition);
}

/* Overlay backdrop */
.menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    z-index: 950;
    opacity: 0;
    transition: opacity var(--transition);
}

body.menu-open .menu-overlay {
    display: block;
    opacity: 1;
}

/* ============================================
   NAVIGATION — Desktop
   ============================================ */
#mainNav {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 2px 12px rgba(30, 58, 138, 0.2);
    position: sticky;
    top: 0;
    z-index: 800;
}

.nav-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 32px;
    height: 62px;
}

.nav-brand {
    font-weight: 700;
    font-size: 17px;
    letter-spacing: 0.3px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-links {
    display: flex;
    gap: 4px;
    flex: 1;
}

.nav-links a {
    color: rgba(255, 255, 255, 0.88);
    text-decoration: none;
    font-weight: 500;
    font-size: 14.5px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    white-space: nowrap;
}

.nav-links a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--white);
}

.nav-actions {
    display: flex;
    align-items: center;
}

.logout-link {
    color: var(--white);
    background: rgba(255, 255, 255, 0.12);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: var(--transition);
}

.logout-link:hover {
    background: var(--white);
    color: var(--primary);
}

/* ============================================
   CONTAINER
   ============================================ */
.container {
    max-width: 1100px;
    margin: 24px auto;
    padding: 28px 32px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

/* ============================================
   HEADINGS
   ============================================ */
h2 {
    color: var(--primary);
    font-size: 22px;
    font-weight: 700;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-light);
    margin-top: 8px;
    margin-bottom: 16px;
}

h2:not(:first-child) {
    margin-top: 32px;
}

/* ============================================
   TABLES
   ============================================ */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 14.5px;
}

th, td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

tr:hover td {
    background: #fafbfe;
}

.low-stock {
    color: var(--danger);
    font-weight: 700;
}

/* ============================================
   FORMS
   ============================================ */
form {
    max-width: 520px;
}

label {
    display: block;
    font-weight: 600;
    color: var(--text);
    margin-top: 14px;
    margin-bottom: 6px;
    font-size: 13.5px;
}

input, select, textarea {
    padding: 11px 14px;
    width: 100%;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    background: var(--white);
    transition: var(--transition);
    color: var(--text);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

button {
    background: var(--primary);
    color: var(--white);
    border: none;
    cursor: pointer;
    padding: 11px 22px;
    font-size: 14.5px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    margin-top: 14px;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(30, 58, 138, 0.2);
}

button:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 14px rgba(30, 58, 138, 0.3);
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

/* ============================================
   BUTTONS — Edit / Delete
   ============================================ */
.btn-edit {
    display: inline-block;
    background: #3b82f6;
    color: #fff;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
    text-decoration: none;
    margin-right: 4px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-edit:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(59, 130, 246, 0.35);
}

.btn-edit:active {
    transform: translateY(0);
}

.btn-danger {
    background: #dc2626;
    color: #fff;
    border: none;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    width: auto;
    margin: 0;
    box-shadow: none;
    transition: all 0.2s ease;
}

.btn-danger:hover {
    background: #b91c1c;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(220, 38, 38, 0.3);
}

.btn-danger:active {
    transform: translateY(0);
}

td .btn-edit,
td .btn-danger {
    vertical-align: middle;
}

/* ============================================
   PRINT SLIP LINK
   ============================================ */
.slip-link {
    display: inline-block;
    background: #eff6ff;
    color: #1e3a8a;
    padding: 5px 12px;
    font-size: 12.5px;
    font-weight: 600;
    border-radius: 6px;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.slip-link:hover {
    background: #1e3a8a;
    color: #fff;
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
    padding: 12px 16px;
    margin: 12px 0;
    border-radius: var(--radius-sm);
    font-size: 14.5px;
    font-weight: 500;
}

.success {
    background: var(--success-soft);
    color: var(--success);
    border-left: 4px solid var(--success);
}

.error {
    background: var(--danger-soft);
    color: var(--danger);
    border-left: 4px solid var(--danger);
}

small {
    color: var(--text-light);
    font-weight: normal;
}

/* ============================================
   RESPONSIVE — TABLET & MOBILE
   ============================================ */

/* Tablet */
@media (max-width: 900px) {
    .container {
        margin: 18px 14px;
        padding: 22px;
    }
    .nav-inner {
        padding: 0 16px;
        gap: 18px;
    }
    .nav-links a {
        padding: 8px 10px;
        font-size: 14px;
    }
}

/* Mobile (≤ 768px) — hamburger menu mode */
@media (max-width: 768px) {

    /* Show mobile topbar */
    .mobile-topbar {
        display: flex;
    }

    /* Convert nav into slide-in drawer */
    #mainNav {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 280px;
        max-width: 82vw;
        background: var(--primary);
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1000;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
        overflow-y: auto;
        border-radius: 0 16px 16px 0;
    }

    body.menu-open #mainNav {
        transform: translateX(0);
    }

    .nav-inner {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        height: auto;
        padding: 22px 18px;
    }

    .nav-brand {
        padding-bottom: 16px;
        margin-bottom: 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.15);
        font-size: 16px;
    }

    .nav-links {
        flex-direction: column;
        gap: 4px;
    }

    .nav-links a {
        padding: 13px 16px;
        font-size: 15.5px;
        border-radius: var(--radius-sm);
        color: var(--white);
        font-weight: 500;
    }

    .nav-links a:hover,
    .nav-links a:active {
        background: rgba(255, 255, 255, 0.15);
    }

    .nav-actions {
        margin-top: 16px;
        padding-top: 16px;
        border-top: 1px solid rgba(255, 255, 255, 0.15);
    }

    .logout-link {
        display: block;
        text-align: center;
        padding: 12px;
        font-size: 15px;
        background: rgba(220, 38, 38, 0.85);
        border-color: transparent;
    }

    .logout-link:hover {
        background: var(--danger);
        color: var(--white);
    }

    /* Container */
    .container {
        margin: 14px 10px;
        padding: 20px 16px;
        border-radius: var(--radius);
    }

    /* Typography */
    h2 {
        font-size: 19px;
    }

    /* Tables → horizontal scroll */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        font-size: 14px;
    }

    th, td {
        padding: 10px 12px;
    }

    /* Forms */
    form {
        max-width: 100%;
    }

    input, select, textarea {
        font-size: 16px; /* prevents iOS auto-zoom */
        padding: 12px 14px;
    }

    button {
        width: 100%;
        padding: 13px;
        font-size: 15px;
    }

    /* Action buttons stay inline on mobile */
    .btn-edit,
    .btn-danger,
    .slip-link {
        padding: 8px 14px !important;
        font-size: 13px !important;
        width: auto !important;
        display: inline-block !important;
        margin: 2px 2px !important;
    }
}

/* Very small phones (≤ 380px) */
@media (max-width: 380px) {
    .nav-brand span { font-size: 15px; }
    .mobile-brand  { font-size: 14px; }
    h2 { font-size: 17px; }
    .container { padding: 16px 12px; }
    th, td { padding: 9px 10px; font-size: 13px; }
}

/* Tap feedback */
@media (hover: none) {
    .nav-links a:active,
    button:active,
    .logout-link:active {
        opacity: 0.75;
    }
}

/* ============================================
   APP FOOTER / COPYRIGHT
   ============================================ */
.app-footer {
    text-align: center;
    padding: 24px 16px 30px;
    margin-top: 40px;
    font-size: 13px;
    color: #94a3b8;
    letter-spacing: 0.2px;
}

.app-footer p {
    margin: 0;
    line-height: 1.6;
}

.app-footer a {
    color: var(--primary);
    font-weight: 700;
    text-decoration: none;
    border-bottom: 1px dashed #cbd5e1;
    transition: all 0.2s ease;
    padding-bottom: 1px;
}

.app-footer a:hover {
    color: var(--primary-light);
    border-bottom-color: var(--primary-light);
}

/* Hide footer when printing */
@media print {
    .app-footer {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .app-footer {
        font-size: 12px;
        padding: 20px 12px 24px;
        margin-top: 30px;
    }
}