/* =========================================
   1. VARIABLES & RESET
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Hind+Siliguri:wght@300;400;500;600;700&display=swap');

:root {
    /* Brand Colors */
    --primary-red: #c1272d;
    --dark-red: #8a1c1c;
    --light-red: #ffebee;
    --gold: #d4af37;
    --light-gold: #fdf5e6;
    
    /* Backgrounds & Text */
    --bg-cream: #f5f0e6;
    --bg-white: #ffffff;
    --text-dark: #2c3e50;
    --text-grey: #636e72;
    --text-light: #f8f8f8;
    
    /* Status Colors */
    --success-bg: #e8f5e9;
    --success-text: #2e7d32;
    --warning-bg: #fff8e1;
    --warning-text: #f57c00;
    --danger-bg: #ffebee;
    --danger-text: #c62828;

    /* Shadows & Radius */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 15px rgba(0,0,0,0.08);
    --radius-md: 8px;
    --radius-lg: 15px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Hind Siliguri', 'Segoe UI', sans-serif; /* Bengali Font */
}

body {
    background-color: var(--bg-cream);
    color: var(--text-dark);
    font-size: 16px;
    line-height: 1.5;
}

.container {
    display: flex;
    min-height: 100vh;
}

/* =========================================
   2. DESKTOP SIDEBAR
   ========================================= */
.sidebar {
    width: 260px;
    background-color: var(--primary-red);
    color: var(--text-light);
    padding: 20px 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 4px 0 10px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

/* Decorative Pattern Overlay */
.bengali-pattern {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path fill="%23d4af37" fill-opacity="0.1" d="M30,10 Q50,0 70,10 Q100,30 90,50 Q100,70 70,90 Q50,100 30,90 Q0,70 10,50 Q0,30 30,10 Z"/></svg>');
    background-size: 150px;
    opacity: 0.2;
    pointer-events: none;
    z-index: 0;
}

.sidebar-header {
    padding: 0 25px 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    position: relative;
    z-index: 1;
}

.sidebar-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--gold);
}

.sidebar-header p {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-top: 5px;
}

.nav-menu {
    margin-top: 20px;
    position: relative;
    z-index: 1;
    flex: 1;
}

.nav-item {
    padding: 14px 25px;
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
    font-weight: 500;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.nav-item.active {
    background-color: rgba(255, 255, 255, 0.12);
    border-left-color: var(--gold);
    color: var(--gold);
}

.nav-item i { width: 20px; text-align: center; }

/* =========================================
   3. MAIN CONTENT & HEADER
   ========================================= */
.main-content {
    flex: 1;
    padding: 25px 35px;
    background-color: #f8f9fa;
    width: 100%;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.header h1 {
    color: var(--dark-red);
    font-size: 1.8rem;
    font-weight: 700;
}

.search-bar {
    display: flex;
    align-items: center;
    background-color: white;
    border-radius: 50px;
    padding: 10px 20px;
    width: 350px;
    box-shadow: var(--shadow-sm);
    border: 1px solid #eee;
    transition: box-shadow 0.3s;
}

.search-bar:focus-within {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-color: var(--gold);
}

.search-bar input {
    border: none;
    background: transparent;
    padding-left: 10px;
    width: 100%;
    outline: none;
    font-size: 0.95rem;
}

/* =========================================
   4. STATS CARDS
   ========================================= */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 35px;
}

.stat-card {
    background-color: white;
    border-radius: var(--radius-md);
    padding: 25px;
    box-shadow: var(--shadow-sm);
    border-top: 4px solid var(--primary-red);
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

.stat-card h3 {
    font-size: 0.9rem;
    color: var(--text-grey);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.stat-card .value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-dark);
}

.stat-card .secondary-value {
    font-size: 0.85rem;
    color: var(--success-text);
    margin-top: 8px;
    font-weight: 500;
}

/* =========================================
   5. TABLES & LISTS
   ========================================= */
.customers-table {
    background-color: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden; /* For rounded corners */
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    background-color: white;
    border-bottom: 1px solid #eee;
}

.table-header h2 {
    font-size: 1.3rem;
    color: var(--text-dark);
}

.table-actions {
    display: flex;
    gap: 12px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background-color: #f8f9fa;
}

th {
    text-align: left;
    padding: 15px 20px;
    font-weight: 600;
    color: var(--text-grey);
    font-size: 0.9rem;
}

td {
    padding: 15px 20px;
    border-bottom: 1px solid #f1f1f1;
    color: var(--text-dark);
    vertical-align: middle;
}

tr:hover {
    background-color: #fcfcfc;
}

/* Customer Avatar & Info */
.customer-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.customer-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background-color: var(--light-gold);
    color: var(--dark-red);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.customer-name { font-weight: 600; color: var(--text-dark); }
.customer-phone { font-size: 0.8rem; color: var(--text-grey); margin-top: 2px; }

/* Status Badges */
.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}
.status-overdue { background-color: var(--danger-bg); color: var(--danger-text); }
.status-due { background-color: var(--warning-bg); color: var(--warning-text); }
.status-paid { background-color: var(--success-bg); color: var(--success-text); }

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--primary-red);
    color: white;
    box-shadow: 0 2px 6px rgba(193, 39, 45, 0.3);
}
.btn-primary:hover { background-color: var(--dark-red); }

.btn-outline {
    background-color: white;
    border: 1px solid #ddd;
    color: var(--text-dark);
}
.btn-outline:hover { background-color: #f5f5f5; }

.action-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    margin-right: 5px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.action-btn.sms { background-color: #e3f2fd; color: #1565c0; }
.action-btn.payment { background-color: var(--success-bg); color: var(--success-text); }

/* =========================================
   6. MODALS & FORMS
   ========================================= */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}

.modal-content {
    background-color: white;
    border-radius: var(--radius-lg);
    width: 600px;
    max-width: 95%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    padding: 20px 25px;
    background-color: var(--primary-red);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.close-btn {
    background: none; border: none;
    color: white; font-size: 1.5rem;
    cursor: pointer; padding: 0 5px;
}

.modal-body { padding: 25px; }

.form-group { margin-bottom: 20px; }
.form-group label {
    display: block; margin-bottom: 8px;
    font-weight: 500; color: var(--text-dark);
}

.form-group input, 
.form-group select, 
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus, 
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-red);
    box-shadow: 0 0 0 3px rgba(193, 39, 45, 0.1);
}

.form-actions {
    display: flex; justify-content: flex-end; gap: 15px; margin-top: 30px;
}
.btn-cancel { background-color: #f1f2f6; color: var(--text-dark); }
.btn-submit { background-color: var(--primary-red); color: white; }

/* Toast */
.toast {
    position: fixed;
    bottom: 30px; right: 30px;
    background-color: #333; color: white;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    z-index: 1100;
    display: flex; align-items: center; gap: 12px;
    transform: translateY(100px); opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background-color: var(--success-text); }
.toast.error { background-color: var(--danger-text); }

/* Mobile Nav (Default Hidden) */
.mobile-nav { display: none; }

/* =========================================
   7. RESPONSIVE / MOBILE STYLES
   ========================================= */

/* Tablet & Mobile (< 992px) */
@media (max-width: 992px) {
    .sidebar { display: none; }

    .mobile-nav {
        display: block;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        background-color: white;
        z-index: 900;
        box-shadow: 0 -5px 20px rgba(0,0,0,0.1);
        padding-bottom: env(safe-area-inset-bottom);
        border-top-left-radius: 20px;
        border-top-right-radius: 20px;
    }

    .mobile-nav-items {
        display: flex; justify-content: space-around;
        padding: 10px 5px;
    }

    .mobile-nav-item {
        flex: 1; text-align: center;
        padding: 8px;
        color: var(--text-grey);
        border-radius: 10px;
        transition: all 0.2s;
    }

    .mobile-nav-item.active {
        color: var(--primary-red);
        background-color: var(--light-red);
    }
    .mobile-nav-item i { font-size: 1.3rem; margin-bottom: 4px; display: block; }
    .mobile-nav-item span { font-size: 0.7rem; font-weight: 500; }

    .main-content {
        padding: 15px;
        padding-bottom: 90px; /* Space for mobile nav */
    }

    .header {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
        position: sticky;
        top: 0;
        z-index: 90;
        background-color: var(--bg-cream);
        margin: -15px -15px 20px -15px;
        padding: 15px 20px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    }

    .search-bar { width: 100%; }

    .stats-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
}

/* Mobile Specific (< 576px) */
@media (max-width: 576px) {
    .stats-cards { grid-template-columns: 1fr; }

    /* CARD VIEW FOR TABLES */
    .customers-table, .modal-body table {
        background: transparent;
        box-shadow: none;
    }
    
    .customers-table thead, .modal-body table thead { display: none; }
    
    .customers-table tbody tr, .modal-body table tbody tr {
        display: block;
        background: white;
        margin-bottom: 15px;
        border-radius: 12px;
        padding: 15px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.05);
        border: 1px solid #eee;
    }

    .customers-table td, .modal-body table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 0;
        border-bottom: 1px solid #f9f9f9;
        text-align: right;
    }

    .customers-table td:last-child {
        border-bottom: none;
        flex-direction: column;
        gap: 10px;
        margin-top: 10px;
    }

    /* Add Labels via Attribute */
    .customers-table td::before, .modal-body table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-grey);
        font-size: 0.85rem;
    }

    .customer-info { width: 100%; }
    
    .table-actions { flex-direction: column; }
    .table-actions .btn-outline { display: none; } /* Hide secondary actions */
    .table-actions .btn { width: 100%; justify-content: center; }

    .customers-table td button, .modal-body table td button {
        width: 100%;
        justify-content: center;
        padding: 10px;
        margin: 0 !important;
    }

    /* BOTTOM SHEET MODAL */
    .modal {
        align-items: flex-end; /* Align to bottom */
    }

    .modal-content {
        width: 100%;
        max-width: 100%;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        border-top-left-radius: 20px;
        border-top-right-radius: 20px;
        max-height: 85vh;
        animation: slideUp 0.3s ease-out;
    }

    @keyframes slideUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }

    .modal-header {
        border-top-left-radius: 20px;
        border-top-right-radius: 20px;
    }

    /* Form Touch Targets */
    input, select, button, .btn { min-height: 48px; }
}