/* Comprehensive Responsive & Professional CRM CSS */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #334155;
    --header-bg: #ffffff;
    --body-bg: #f1f5f9;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--body-bg);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.wrapper { display: flex; min-height: 100vh; position: relative; }

/* Fixed Header */
.header {
    background: var(--header-bg);
    height: 60px;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.header-left { display: flex; align-items: center; gap: 15px; }
.header-left h1 { font-size: 1rem; font-weight: 700; color: #0f172a; }

.menu-toggle {
    background: #f1f5f9;
    border: none;
    width: 38px; height: 38px;
    border-radius: 8px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-main);
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    height: 100vh;
    position: fixed;
    top: 0; left: 0;
    z-index: 1000;
    padding-top: 60px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}
.sidebar.closed { transform: translateX(-100%); width: 0; }

.main-content {
    flex-grow: 1;
    margin-left: 260px;
    margin-top: 60px;
    padding: 30px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: calc(100vh - 60px);
    width: calc(100% - 260px);
}
.main-content.expanded { margin-left: 0; width: 100%; }

/* Mobile Menu Slide-Out */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); width: 280px; }
    .sidebar.open { transform: translateX(0); box-shadow: 10px 0 30px rgba(0,0,0,0.2); }
    .main-content { margin-left: 0; width: 100%; padding: 20px; }
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    display: none;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* General Content Styling */
.card-container {
    background: #fff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 25px;
}

/* Field & Label Styling */
.form-group { margin-bottom: 15px; }
.form-group label { 
    display: block; 
    margin-bottom: 8px; 
    font-weight: 600; 
    font-size: 0.875rem; 
    color: #475569; 
}
input[type="text"], input[type="number"], input[type="email"], input[type="password"], input[type="date"], input[type="datetime-local"], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text-main);
    background-color: #fff;
    transition: all 0.2s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Button Styling */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #e2e8f0; color: #475569; }
.btn-secondary:hover { background: #cbd5e1; }
.btn-info { background: var(--info); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }

/* Table Styling (View Template Standard) */
.data-table-container { width: 100%; overflow-x: auto; border-radius: 8px; border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; background: #fff; }
.data-table thead tr { background-color: #1e293b; color: #fff; }
.data-table th {
    padding: 12px 15px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #334155;
    white-space: nowrap;
}
.data-table td { 
    padding: 12px 15px; 
    border-bottom: 1px solid var(--border); 
    font-size: 11px; 
    color: var(--text-main);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background-color: #f8fafc; }

/* Smooth Page Transitions */
body {
    animation: fadeIn 0.4s ease-out;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Advanced Card Hover Effects */
.card-container {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

/* Modern Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Enhanced Button Interactions */
.btn {
    position: relative;
    overflow: hidden;
}
.btn:active { transform: scale(0.96); }
.btn i { transition: transform 0.2s; }
.btn:hover i { transform: translateX(2px); }

/* Glassmorphism for sidebar items on hover */
.sidebar ul li a:hover {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(4px);
    border-left: 4px solid var(--primary);
    padding-left: 16px !important;
}
.sidebar ul li a {
    transition: all 0.2s;
    border-left: 4px solid transparent;
}


/* Mobile & Tablet Reflow content */
@media (max-width: 768px) {
    .main-content { padding: 15px; }
    .card-container { padding: 15px; }
    .header-section { flex-direction: column; align-items: flex-start; gap: 10px; }
    
    /* Table to Card conversion for mobile */
    .data-table.mobile-reflow thead { display: none; }
    .data-table.mobile-reflow tr { 
        display: block; 
        margin-bottom: 15px; 
        border: 1px solid var(--border); 
        border-radius: 10px; 
        padding: 10px;
        background: #fff;
    }
    .data-table.mobile-reflow td { 
        display: flex; 
        justify-content: space-between; 
        align-items: center; 
        border: none; 
        padding: 8px 5px; 
        text-align: right; 
    }
    .data-table.mobile-reflow td::before { 
        content: attr(data-label); 
        font-weight: 800; 
        color: #94a3b8; 
        font-size: 0.75rem; 
        text-transform: uppercase;
        text-align: left;
    }
}

/* Modal Hide on Print */
@media print {
    .modal, .sidebar, .header, .no-print, .btn { display: none !important; }
    .main-content { margin: 0 !important; width: 100% !important; padding: 0 !important; }
    .wrapper { display: block !important; }
}

.badge { padding: 5px 12px; border-radius: 20px; font-size: 0.7rem; font-weight: 800; text-transform: uppercase; display: inline-flex; }
.badge-paid { background: #dcfce7; color: #15803d; }
.badge-unpaid { background: #fee2e2; color: #b91c1c; }
/* Payment History Component */
.payment-history-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 15px;
    margin-top: 15px;
}
.payment-history-title {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    color: #64748b;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 8px;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}
.payment-history-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 0.85rem;
    color: var(--text-main);
}
.payment-amount-success { color: #10b981; font-weight: 700; }
.balance-due-box {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 2px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    font-weight: 800;
    font-size: 1rem;
    color: #ef4444;
}
.fully-paid-badge {
    background: #10b981;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    text-align: center;
    font-weight: 800;
    font-size: 0.75rem;
    text-transform: uppercase;
}
