/* =========================================
   B2B Order Portal Global Stylesheet
   ========================================= */

:root {
    /* Color Palette */
    --primary-color: #0f172a; /* Slate 900 */
    --primary-hover: #1e293b; /* Slate 800 */
    --accent-color: #2563eb;  /* Blue 600 */
    --accent-hover: #1d4ed8;  /* Blue 700 */
    --danger-color: #ef4444;  /* Red 500 */
    --danger-bg: #fee2e2;     /* Red 100 */
    --success-color: #10b981; /* Emerald 500 */
    --success-bg: #d1fae5;    /* Emerald 100 */
    
    /* Backgrounds & Surfaces */
    --bg-main: #f8fafc;       /* Slate 50 */
    --bg-card: #ffffff;
    --border-color: #e2e8f0;  /* Slate 200 */
    
    /* Text */
    --text-main: #0f172a;
    --text-muted: #64748b;    /* Slate 500 */
    
    /* Layout */
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --transition-speed: 0.2s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

html, body {
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    padding: 0;
    margin: 0;
    width: 100%;
    overflow-x: hidden; /* Prevent horizontal sliding */
    position: relative;
    -webkit-font-smoothing: antialiased;
}

* {
    -webkit-tap-highlight-color: transparent;
}

/* --- Utility Classes --- */
.hidden { display: none !important; }

/* --- Mockup Login UI --- */
.login-wrapper {
    width: 100%;
    min-height: 100vh;
    background: url('background.jpg') no-repeat center center fixed;
    background-size: cover;
    display: flex;
    position: relative;
}

.login-sidebar {
    width: 380px;
    background: rgba(20, 20, 20, 0.9); /* Dark semi-transparent */
    backdrop-filter: blur(5px);
    padding: 60px 40px;
    display: flex;
    flex-direction: column;
    z-index: 2;
    box-shadow: 10px 0 30px rgba(0,0,0,0.3);
}

.logo-area {
    margin-bottom: 20px; /* Reduced to allow for larger image logo */
    text-align: center;
}

.main-logo {
    max-width: 100%;
    height: auto;
    max-height: 120px;
    object-fit: contain;
}

.login-subtitle {
    color: #94a3b8;
    font-size: 14px;
    margin-bottom: 30px;
}

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

.input-group label {
    display: block;
    color: #f1f5f9;
    font-size: 13px;
    margin-bottom: 8px;
    font-weight: 500;
}

.input-group input {
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-radius: 4px;
    background: #f1f5f9;
    color: #1e293b;
    font-size: 15px;
    box-shadow: 0 0 10px rgba(255,255,255,0.1);
}

.input-group input:focus {
    outline: none;
    box-shadow: 0 0 10px rgba(255,255,255,0.4);
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 30px;
}

.btn-login {
    background: #eab308; /* Yellow/Gold */
    color: #1e293b;
    border: none;
    padding: 10px 24px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
}

.btn-reset {
    background: white;
    color: #1e293b;
    border: none;
    padding: 10px 24px;
    border-radius: 4px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
}

.sidebar-footer {
    margin-top: auto;
    font-size: 12px;
    color: #3b82f6;
}

.sidebar-footer a {
    color: #3b82f6;
    text-decoration: none;
}

/* Spinner adjustment for new btn */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: #000;
    animation: spin 1s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 600px) {
    .login-sidebar {
        width: 100%;
        background: rgba(20, 20, 20, 0.95);
    }
}

/* --- Tom Select Overrides --- */
.ts-control {
    padding: 12px 16px !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--border-radius-sm) !important;
    font-size: 15px !important;
    background-color: #f8fafc !important;
    box-shadow: none !important;
    min-height: 48px;
    display: flex;
    align-items: center;
}

.ts-control.focus {
    border-color: var(--accent-color) !important;
    background-color: #ffffff !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1) !important;
}

.ts-wrapper.single .ts-control::after {
    border-color: var(--text-muted) transparent transparent transparent !important;
    border-width: 5px 5px 0 5px !important;
}

.ts-wrapper {
    margin-bottom: 20px;
}

/* =========================================
   Responsive Dashboard & Grid System
   ========================================= */

.dashboard-container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 16px;
}

.stat-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-card);
    padding: 20px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    display: flex;
    flex-direction: column;
}

.stat-lbl { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-val { font-size: 26px; font-weight: 700; color: var(--primary-color); }
.stat-val.danger { color: var(--danger-color); }

.form-section, .history-section, .card {
    background: var(--bg-card);
    padding: 25px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    margin-bottom: 30px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}

.form-section h3, .history-section h3, .card-header h3 {
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: 700;
}

/* Tables */
.table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* Smooth iOS scroll */
    margin: 0 -25px; /* Offset section padding to let table bleed if needed */
    padding: 0 25px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; /* Force scroll on very small screens */
}

th, td {
    padding: 14px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

th {
    color: var(--text-muted);
    font-weight: 600;
    background-color: #f8fafc;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

/* Admin Specific */
.topbar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 15px 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    margin-bottom: 30px;
}

.admin-action {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.status-pending { background: #fef3c7; color: #d97706; }
.status-completed { background: var(--success-bg); color: var(--success-color); }

/* =========================================
   Perfect Mobile Optimization (@Media)
   ========================================= */

@media (max-width: 768px) {
    .dashboard-container { padding: 15px; }
    
    .header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

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

    .stat-card {
        padding: 16px;
        align-items: center;
        text-align: center;
    }

    .stat-val { font-size: 24px; }
    
    .form-section, .history-section, .card {
        padding: 20px;
    }

    .topbar {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }

    /* Prevent text stretching on small screens */
    h2 { font-size: 20px; }
    h1, .stat-val { word-break: break-word; }

    .table-container {
        margin: 0 -20px;
        padding: 0 20px;
    }

    /* Fixed Aspect Ratio for Logo */
    .logo-box {
        width: 54px;
        height: 54px;
        font-size: 18px;
        flex-shrink: 0;
    }
}

/* Ultra Small Devices (e.g. iPhone SE) */
@media (max-width: 380px) {
    .login-card {
        padding: 30px 20px;
    }
    
    .dashboard-container {
        padding: 10px;
    }
    
    .stat-card {
        padding: 15px;
    }
}

/* --- Modal Styles --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: #1e293b; /* Dark slate */
    color: #f1f5f9;
    padding: 30px;
    border-radius: 12px;
    max-width: 500px;
    width: 100%;
    position: relative;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    border: 1px solid #334155;
    animation: modalFadeIn 0.3s ease-out;
}

.modal-body {
    max-height: 400px;
    overflow-y: auto;
    margin-top: 20px;
    font-size: 14px;
    line-height: 1.6;
    color: #cbd5e1;
}

.modal-body h3 {
    margin: 20px 0 10px;
    font-size: 16px;
    color: #f1f5f9;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #94a3b8;
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover {
    color: #ffffff;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 600px) {
    .modal-content {
        padding: 20px;
    }
}
