/*
    Suntek Customer Portal - Modern Design System
    Focus: Clean, Professional, Swiss-style UI
*/

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden !important; /* Proper horizontal safety */
    max-width: 100%;
    margin: 0;
    padding: 0;
    scroll-behavior: auto !important; /* Disable smooth scroll which causes drift */
}

/* Premium Native Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: #f1f1f1;
}
::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

:root {
    --primary: #C62828;
    --primary-light: #EF5350;
    --primary-dark: #B71C1C;
    --bg-main: #F4F7F9;
    --bg-surface: #FFFFFF;
    --text-main: #2C3E50;
    --text-muted: #7F8C8D;
    --border-color: #E0E6ED;
    --radius-sm: 3px;
    --radius-md: 4px; /* Even smaller */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 3px 5px -1px rgba(0,0,0,0.06);
}

body {
    background-color: var(--bg-main) !important;
    font-family: 'Open Sans', 'Segoe UI', Tahoma, sans-serif !important;
    color: var(--text-main);
    line-height: 1.4; 
    font-size: 12.5px !important; /* Balanced density */
    overflow-x: hidden !important;
}

@media screen and (max-width: 768px) {
    body {
        font-size: 13px !important;
    }
}

/* Typography Overrides */
h1, h2, h3, h4, .brand-text {
    font-weight: 700 !important;
    letter-spacing: -0.02em;
}

/* Professional Cards */
.st-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 15px; /* Balanced room */
    margin-bottom: 15px;
}

input[type="text"], 
input[type="password"], 
.form-control {
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-sm) !important;
    padding: 6px 12px !important; 
    min-height: 30px !important; 
    height: 30px !important;
    background: #FFF !important;
    box-shadow: none !important;
    transition: all 0.2s !important;
    display: block !important;
    width: 100% !important;
    font-size: 12.5px !important;
    line-height: normal !important;
    color: var(--text-main) !important;
    box-sizing: border-box !important;
    margin: 0 !important;
}

/* Table Design System (Highly Compressed) */
.st-table-container {
    width: 100% !important;
    overflow-x: auto !important;
    display: block !important;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    margin-top: 10px;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-x: contain !important; /* Prevent scroll leaking to page */
}

.st-table {
    display: table !important;
    width: auto !important;
    min-width: 100% !important;
    border-collapse: collapse !important;
    font-size: 12px !important; /* Balanced density */
    table-layout: auto !important;
}

    .st-table th {
        display: table-cell !important;
        background: #edff00 !important;
        color: var(--text-main) !important;
        font-weight: 700 !important;
        text-align: left !important;
        padding: 6px 10px !important; /* Balanced room */
        border-bottom: 2px solid var(--border-color) !important;
        border-right: 1px solid var(--border-color) !important;
        white-space: nowrap !important;
    }

.st-table td {
    display: table-cell !important;
    padding: 6px 10px !important; /* Balanced room */
    border-bottom: 1px solid var(--border-color) !important;
    border-right: 1px solid var(--border-color) !important;
    color: var(--text-main) !important;
    vertical-align: middle !important;
    white-space: normal !important; 
    word-break: break-word !important;
}

select.form-control, 
.st-card select.form-control {
    padding: 0 35px 0 10px !important; /* Minimal vertical padding to prevent clipping */
    line-height: 30px !important; /* Match total height for centering */
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 10px center !important;
    background-size: 14px !important;
    cursor: pointer !important;
}

input[type="text"]:focus, 
input[type="password"]:focus,
.form-control:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.1) !important;
    outline: none !important;
}

/* Premium Buttons */
.st-btn-primary {
    background-color: var(--primary) !important;
    color: white !important;
    border: none !important;
    padding: 0 15px !important; 
    border-radius: var(--radius-sm) !important;
    font-weight: 600 !important;
    font-size: 12.5px !important; 
    cursor: pointer !important;
    transition: background-color 0.2s !important;
    height: 30px !important; 
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
}

.st-btn-primary:hover {
    background-color: var(--primary-dark) !important;
}

/* Layout Cleanup */
.navbar-fixed-bottom {
    background: #2C3E50 !important;
    border-top: 1px solid rgba(255,255,255,0.1) !important;
    color: #FFF !important;
    padding: 10px 0 !important;
}

.navbar-fixed-bottom a {
    color: var(--primary-light) !important;
    text-decoration: underline;
}

/* Login Page Specifics */
.login-page {
    margin: 0 !important;
    padding: 0 !important;
}

.login-page-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding-bottom: 60px; /* Space for footer */
}

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

.login-card {
    text-align: center;
    padding: 50px !important;
    border: none !important;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05) !important;
}

.login-brand img {
    height: 70px;
    margin-bottom: 30px;
}

.login-title {
    font-size: 18px; /* Balanced title */
    color: var(--text-main);
    margin-bottom: 15px; 
    font-weight: 800 !important;
}

.login-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1a222c !important;
    padding: 15px 0;
    text-align: center;
    color: rgba(255,255,255,0.7);
    font-size: 12px;
    z-index: 10;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.login-footer a {
    color: var(--primary-light) !important;
    font-weight: 600;
}

.form-group {
    text-align: left;
    margin-bottom: 15px; /* Denser */
    display: flex;
    flex-direction: column;
}

.form-group label {
    display: block;
    margin-bottom: 4px; 
    font-weight: 600;
    font-size: 12.5px; /* Balanced */
    color: #4A5568;
    text-transform: none;
}

.login-submit {
    width: 100% !important;
    margin-top: 15px !important;
    height: 48px !important;
    font-size: 16px !important;
}

.password-group {
    position: relative;
}

.toggle-password {
    position: absolute;
    right: 14px;
    bottom: 12px;
    cursor: pointer;
    color: #A0AEC0;
    font-size: 18px;
    z-index: 5;
    transition: color 0.2s;
}

.toggle-password:hover {
    color: var(--primary);
}

/* Master Layout Navigation */
.st-header {
    background: #FFF;
    border-bottom: 1px solid var(--border-color);
    height: 48px; /* Balanced height */
    display: grid; 
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 20px; 
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.st-brand {
    justify-self: start;
    display: flex;
    align-items: center;
    gap: 15px;
}

.st-customer-name-center {
    justify-self: center;
    font-weight: 700;
    color: var(--primary);
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.st-user-area {
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Sidebar Toggle (Hidden on Desktop) */
.st-menu-toggle {
    display: none;
    font-size: 20px;
    cursor: pointer;
    margin-right: 15px;
}

/* Sidebar Styles */
.st-sidebar {
    position: fixed;
    top: 48px; /* Match header height */
    left: 0;
    bottom: 0;
    width: 210px; /* Standard professional width */
    background: #1a222c;
    color: #FFF;
    overflow-y: auto;
    z-index: 2000; 
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), width 0.4s ease;
}

.st-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.st-sidebar-overlay.show {
    display: block;
    opacity: 1;
}

.st-nav-menu {
    padding: 15px 0;
}

.st-nav-item {
    display: flex;
    align-items: center;
    padding: 8px 15px; /* Breathing room */
    color: rgba(255,255,255,0.65);
    text-decoration: none !important;
    transition: all 0.2s;
    font-size: 13px; /* Balanced readable */
    font-weight: 500;
    gap: 12px;
}

.st-nav-item i {
    width: 20px;
    text-align: center;
}

.st-nav-item:hover, .st-nav-item.active {
    color: #FFF !important;
    background: rgba(255,255,255,0.05);
}

.st-nav-item.active {
    border-left: 4px solid var(--primary);
}

/* Modal System */
.st-modal-overlay {
    background: rgba(0,0,0,0.4) !important;
    backdrop-filter: blur(4px);
}

.st-modal-card {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 360px;
    border: none !important;
    border-radius: var(--radius-md) !important;
    overflow: hidden;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04) !important;
    z-index: 1001;
}

.st-modal-header {
    background: var(--primary) !important;
    color: #FFF !important;
    padding: 20px 25px !important;
}

/* Main Content Wrapper */
.st-main-content {
    margin-top: 48px; /* Match header height */
    margin-left: 210px; /* Match sidebar width */
    padding: 20px 25px; /* Balanced room */
    min-height: calc(100vh - 48px);
    transition: all 0.3s ease;
    overflow-x: hidden !important; /* Extremely important for diagonal scroll fix */
}

/* Responsiveness (Media Queries) */
@media (max-width: 992px) {
    .st-sidebar {
        width: 70px; /* Mini sidebar */
    }
    .st-nav-item span {
        display: none;
    }
    .st-nav-item i {
        font-size: 18px;
        margin: 0;
    }
    .st-main-content {
        margin-left: 70px;
    }
    .st-customer-name-center {
        font-size: 13px;
    }
}

@media (max-width: 768px) {
    .st-menu-toggle {
        display: block;
    }
    .st-sidebar {
        transform: translateX(-100%); 
        width: 210px;
        box-shadow: 10px 0 15px -3px rgba(0, 0, 0, 0.1);
    }
    .st-sidebar.open {
        transform: translateX(0);
    }
    .st-main-content {
        margin-left: 0;
        margin-top: 48px;
        padding: 15px 12px;
    }
    .st-customer-name-center {
        display: none; /* Hide in center for more space */
    }
    .st-brand img {
        height: 28px;
    }
    .st-user-welcome {
        display: none;
    }
}

/* Section Titles */
.st-section-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    margin: 30px 0 15px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.st-section-title i {
    font-size: 18px;
}

/* Status Badges */
.st-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-block;
}

.st-badge-success { background: #e6f7ec; color: #1a7a42; } /* Delivered */
.st-badge-warning { background: #fff3cd; color: #856404; } /* Pending/UnDelivered */
.st-badge-info { background: #e7f3ff; color: #004085; } /* In Transit */
.st-badge-danger { background: #fceaea; color: #a51f1f; } /* Cancelled */

/* Header Adjustments */
.dash-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px;
    padding: 20px 0;
}

.dash-item {
    text-align: center;
    transition: transform 0.2s;
}

.dash-item:hover {
    transform: translateY(-5px);
}

.dash-card-icon {
    width: 80px; /* Reduced from 100 */
    height: 80px;
    object-fit: contain;
    padding: 12px;
    background: #FFF;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
}

.dash-card-label {
    display: block;
    background: var(--primary) !important;
    color: white !important;
    padding: 6px 4px; /* Reduced */
    border-radius: var(--radius-sm);
    font-size: 12px; /* Reduced */
    font-weight: 600;
    text-transform: uppercase;
    width: 100px; /* Reduced from 120 */
    margin: 0 auto;
}

/* Alerts & Notifications */
.st-alert {
    padding: 15px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-weight: 500;
}
.st-alert-info { background: #e7f3ff !important; color: #004085 !important; border: 1px solid #cce5ff !important; }
.st-alert-warning { background: #fff3cd !important; color: #856404 !important; border: 1px solid #ffeeba !important; }
.st-alert-danger { background: #f8d7da !important; color: #721c24 !important; border: 1px solid #f5c6cb !important; }
.st-alert-success { background: #d4edda !important; color: #155724 !important; border: 1px solid #c3e6cb !important; }

/* Search Filter Areas (High Density) */
.st-search-area {
    background: #f8f9fa !important;
    padding: 15px 20px !important;
    border-radius: var(--radius-sm) !important;
    margin-bottom: 20px !important;
    border: 1px solid var(--border-color);
}

.st-search-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) !important;
    gap: 15px !important;
    align-items: flex-end !important;
}

/* Radio Button Lists */
.st-radio-list label {
    margin-left: 4px;
    margin-right: 12px;
    cursor: pointer;
    font-size: 11px; /* Tiny density */
}

.st-radio-list input[type="radio"] {
    transform: scale(0.8); /* Shrink radio buttons */
    vertical-align: middle;
}
