
/* ============================================
   Reset & Base Styles
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    width: 100%;
}

:root {
    --primary: #0E7490;
    --secondary: #155E75;
    --bg: #F8FAFC;
    --surface: #FFFFFF;
    --text-primary: #1E293B;
    --text-secondary: #64748B;
    --success: #10B981;
    --danger: #EF4444;
    --border: #E2E8F0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

@font-face {
    font-family: 'Inter';
    src: local('Inter'), url('https://fonts.gstatic.com/s/inter/v13/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMw2boKodrIe82P.woff2') format('woff2');
    font-weight: 400 700;
    font-display: swap;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
}

/* ============================================
   Login Page Styles
   ============================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: var(--surface);
    padding: 40px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header .logo {
    width: 80px;
    height: 80px;
    margin-bottom: 16px;
}

.login-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 16px;
}

/* ============================================
   Form Styles
   ============================================ */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group label .required {
    color: var(--danger);
    margin-left: 2px;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: all 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14, 116, 144, 0.15);
}

textarea {
    min-height: 80px;
    resize: vertical;
}

/* ============================================
   Button Styles
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--secondary);
    transform: scale(1.02);
}

.btn-secondary {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-secondary:hover {
    background: var(--primary);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-small {
    padding: 6px 16px;
    font-size: 13px;
}

.btn-full {
    width: 100%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* ============================================
   Messages & Toasts
   ============================================ */
.message {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
}

.message.success {
    background: #D1FAE5;
    color: #065F46;
}

.message.error {
    background: #FEE2E2;
    color: #991B1B;
}

/* ============================================
   Layout Styles (Sidebar, Main)
   ============================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--secondary);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
}

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

.sidebar-header .logo {
    width: 40px;
    height: 40px;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.sidebar-nav {
    padding: 16px 0;
    flex: 1;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: all 0.2s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--primary);
    color: white;
}

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-footer .user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-footer .user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.main-content {
    margin-left: 240px;
    flex: 1;
    padding: 32px;
    max-width: 1200px;
}

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

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

/* ============================================
   Card Styles
   ============================================ */
.card {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}

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

.card-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ============================================
   Table Styles
   ============================================ */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    background: var(--primary);
    color: white;
    font-weight: 600;
    text-align: left;
    padding: 12px 12px;
    font-size: 14px;
}

table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

table tbody tr:nth-child(even) {
    background: var(--bg);
}

table tbody tr:hover {
    background: #F0FDFA;
}

/* ============================================
   Grid Layout for Forms
   ============================================ */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

@media (max-width: 768px) {
    .grid-2,
    .grid-4 {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Dashboard Cards
   ============================================ */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 20px;
    border-left: 4px solid var(--primary);
}

.stat-card h3 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.stat-card p {
    font-size: 14px;
    color: var(--text-secondary);
}

@media (max-width: 1024px) {
    .dashboard-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile header and overlay styles */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.mobile-header {
    display: none;
    align-items: center;
    padding: 12px 20px;
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    gap: 12px;
}

.mobile-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
}

.hamburger-btn {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    z-index: 101;
}

.hamburger-btn span {
    width: 25px;
    height: 3px;
    background: var(--primary);
    border-radius: 2px;
}

@media (max-width: 768px) {
    .dashboard-cards {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
        z-index: 100;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.open {
        display: block;
    }

    .mobile-header {
        display: flex;
        position: sticky;
        top: 0;
        z-index: 98;
        margin-bottom: 0;
    }

    .main-content {
        margin-left: 0;
        padding: 0 0 20px 0;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .main-content > *:not(.mobile-header) {
        padding: 16px;
    }
}

/* ============================================
   Status Badges
   ============================================ */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-pending {
    background: #FEF3C7;
    color: #92400E;
}

.status-in_progress {
    background: #DBEAFE;
    color: #1E40AF;
}

.status-ready {
    background: #D1FAE5;
    color: #065F46;
}

.status-delivered {
    background: #D1FAE5;
    color: #065F46;
}

.status-not_delivered {
    background: #FEE2E2;
    color: #991B1B;
}

/* ============================================
   Action Buttons (Edit/Delete)
   ============================================ */
.action-buttons {
    display: flex;
    gap: 8px;
}

.btn-icon {
    padding: 6px 10px;
    font-size: 12px;
}

/* ============================================
   Enhanced Mobile Responsive Styles
   ============================================ */
@media (max-width: 768px) {
    .card {
        padding: 16px;
        border-radius: 8px;
        width: 100%;
        box-sizing: border-box;
    }

    .card-header {
        padding-bottom: 12px;
        margin-bottom: 16px;
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .card-header h2 {
        font-size: 16px;
    }

    .dashboard-cards {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-card h3 {
        font-size: 28px;
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        box-sizing: border-box;
    }

    table {
        font-size: 13px;
        min-width: 600px;
    }

    table th,
    table td {
        padding: 8px 10px;
    }

    .grid-2,
    .grid-4 {
        grid-template-columns: 1fr;
        gap: 12px;
    }

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

    .page-header h1 {
        font-size: 20px;
    }

    .main-content > *:not(.mobile-header) {
        padding: 16px;
    }

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

    .btn {
        padding: 10px 16px;
        font-size: 14px;
    }

    .btn-full {
        width: 100%;
    }

    .action-buttons {
        flex-wrap: wrap;
    }

    /* Make sure the body and html don't overflow */
    html, body {
        overflow-x: hidden;
        width: 100%;
    }

    /* Make totals section responsive */
    .totals-section {
        align-items: stretch !important;
    }

    .totals-section > div {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 1024px) {
    .dashboard-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}
