/* Deepam Audios ERP - Modern Responsive UI */
:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --dark: #1e293b;
    --light: #f8fafc;
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --header-height: 60px;
    --border-radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px 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);
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f1f5f9;
    margin: 0;
    min-height: 100vh;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

/* ==================== LOGIN PAGE ==================== */
.login-page {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-box {
    background: white;
    border-radius: var(--border-radius);
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    color: var(--primary);
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 8px;
}

.login-header p {
    color: var(--secondary);
    margin: 0;
    font-size: 14px;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--dark) 0%, #0f172a 100%);
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
}

.sidebar-logo {
    color: white;
    font-size: 18px;
    font-weight: 700;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.sidebar-logo i {
    font-size: 24px;
    color: var(--primary-light);
    flex-shrink: 0;
}

.sidebar-logo-img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    flex-shrink: 0;
    background: white;
    border-radius: 4px;
    padding: 2px;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
}

.sidebar-nav {
    padding: 15px 0;
    flex: 1;
    overflow-y: auto;
}

.nav-section {
    padding: 10px 20px 5px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.4);
    font-weight: 600;
}

.nav-item {
    padding: 0 12px;
    margin-bottom: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    font-size: 13px;
    white-space: nowrap;
}

.nav-link:hover, .nav-link.active {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-link.active {
    background: var(--primary);
}

.nav-link i {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

/* ==================== HEADER ==================== */
.header {
    background: white;
    height: var(--header-height);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 15px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
    min-width: 0;
    flex: 1;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--dark);
    cursor: pointer;
    padding: 5px;
    flex-shrink: 0;
}

.header-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.location-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--light);
    border-radius: 8px;
    font-size: 13px;
}

.location-selector i {
    color: var(--primary);
}

.location-selector select {
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    max-width: 120px;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.user-info {
    display: block;
}

.user-info .name {
    font-weight: 500;
    font-size: 14px;
    color: var(--dark);
}

.user-info .role {
    font-size: 12px;
    color: var(--secondary);
}

/* ==================== PAGE CONTENT ==================== */
.page-content {
    padding: 20px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 15px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--dark);
    margin: 0;
}

/* ==================== CARDS ==================== */
.card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border: none;
    overflow: hidden;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid #e2e8f0;
    padding: 16px 20px;
    font-weight: 600;
    font-size: 15px;
}

.card-body {
    padding: 20px;
}

/* ==================== STATS CARDS ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-icon.primary { background: rgba(79,70,229,0.1); color: var(--primary); }
.stat-icon.success { background: rgba(16,185,129,0.1); color: var(--success); }
.stat-icon.warning { background: rgba(245,158,11,0.1); color: var(--warning); }
.stat-icon.danger { background: rgba(239,68,68,0.1); color: var(--danger); }
.stat-icon.info { background: rgba(59,130,246,0.1); color: var(--info); }

.stat-content {
    min-width: 0;
    flex: 1;
}

.stat-content h3 {
    font-size: 24px;
    font-weight: 700;
    color: var(--dark);
    margin: 0 0 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-content p {
    color: var(--secondary);
    margin: 0;
    font-size: 13px;
}

.stat-change {
    font-size: 12px;
    margin-top: 8px;
}

.stat-change.positive { color: var(--success); }
.stat-change.negative { color: var(--danger); }

/* ==================== TABLES ==================== */
.table-container {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.table-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--dark);
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.table th {
    background: #f8fafc;
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--secondary);
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
    vertical-align: middle;
}

/* Prevent number overflow in table cells */
.table td strong,
.table td .text-success,
.table td .text-danger,
.table td .text-warning {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table tbody tr:hover {
    background: #f8fafc;
}

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-info {
    background: var(--info);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid #e2e8f0;
    color: var(--dark);
}

.btn-outline:hover {
    background: #f8fafc;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-lg {
    padding: 14px 24px;
    font-size: 15px;
}

/* ==================== FORMS ==================== */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--dark);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 10px center;
    background-repeat: no-repeat;
    background-size: 20px;
    padding-right: 40px;
}

/* ==================== BADGES ==================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
}

.badge-success { background: rgba(16,185,129,0.1); color: var(--success); }
.badge-warning { background: rgba(245,158,11,0.1); color: var(--warning); }
.badge-danger { background: rgba(239,68,68,0.1); color: var(--danger); }
.badge-info { background: rgba(59,130,246,0.1); color: var(--info); }
.badge-primary { background: rgba(79,70,229,0.1); color: var(--primary); }
.badge-secondary { background: rgba(100,116,139,0.1); color: var(--secondary); }

/* ==================== MODALS ==================== */
.modal-content {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 1px solid #e2e8f0;
    padding: 16px 20px;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    border-top: 1px solid #e2e8f0;
    padding: 16px 20px;
}

/* ==================== ALERTS ==================== */
.alert {
    padding: 18px 24px;
    border-radius: 12px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 16px;
    font-weight: 500;
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
    animation: slideInRight 0.4s ease-out;
}

.alert i {
    font-size: 28px;
    flex-shrink: 0;
}

.alert-success { 
    background: #10b981; 
    color: white; 
    border-left: 6px solid #047857;
}
.alert-danger { 
    background: #ef4444; 
    color: white; 
    border-left: 6px solid #b91c1c;
}
.alert-warning { 
    background: #f59e0b; 
    color: white; 
    border-left: 6px solid #b45309;
}
.alert-info { 
    background: #3b82f6; 
    color: white; 
    border-left: 6px solid #1d4ed8;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* ==================== FILTERS ==================== */
.filters-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ==================== QUICK ACTIONS ==================== */
.quick-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* ==================== EMPTY STATE ==================== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--secondary);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 16px;
    margin: 0 0 8px;
    color: var(--dark);
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ==================== RESPONSIVE - TABLET ==================== */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stat-content h3 {
        font-size: 20px;
    }
    
    .page-content {
        padding: 16px;
    }
}

/* ==================== RESPONSIVE - MOBILE ==================== */
@media (max-width: 768px) {
    /* Sidebar */
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .sidebar-close {
        display: block;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    /* Main Content */
    .main-content {
        margin-left: 0;
    }
    
    /* Header */
    .menu-toggle {
        display: block;
    }
    
    .header {
        padding: 0 15px;
    }
    
    .header-title {
        font-size: 16px;
    }
    
    .location-selector {
        display: flex;
        margin-right: 8px;
    }
    
    .location-selector select {
        font-size: 13px;
        max-width: 120px;
    }
    
    .user-info {
        display: none;
    }
    
    /* Page */
    .page-content {
        padding: 15px;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .page-title {
        font-size: 20px;
    }
    
    /* Stats */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    
    .stat-card {
        padding: 15px;
        flex-direction: column;
        text-align: center;
    }
    
    .stat-icon {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
    
    .stat-content h3 {
        font-size: 18px;
    }
    
    .stat-content p {
        font-size: 12px;
    }
    
    /* Tables - CRITICAL FIX */
    .table-container {
        overflow: hidden;
    }
    
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0;
        width: 100%;
    }
    
    .table {
        min-width: 700px;
    }
    
    .table th, .table td {
        padding: 10px 12px;
        font-size: 12px;
    }
    
    /* Hide less important columns on mobile */
    .table .hide-mobile {
        display: none;
    }
    
    /* Filters */
    .filters-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .filter-group .form-control,
    .filter-group .form-select {
        width: 100%;
    }
    
    /* Buttons */
    .btn {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .btn-lg {
        padding: 12px 20px;
        width: 100%;
    }
    
    /* Quick Actions */
    .quick-actions {
        flex-direction: column;
    }
    
    .quick-actions .btn {
        width: 100%;
    }
    
    /* Cards */
    .card-header, .card-body {
        padding: 15px;
    }
    
    /* Modals */
    .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    .modal-body {
        padding: 15px;
        max-height: 70vh;
        overflow-y: auto;
    }
    
    .modal-lg, .modal-xl {
        max-width: calc(100% - 20px);
    }
    
    /* Row adjustments */
    .row > [class*="col-"] {
        margin-bottom: 15px;
    }
    
    /* Form rows on mobile */
    .row.g-3 > [class*="col-md-"],
    .row.g-3 > [class*="col-lg-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    /* Action buttons in tables */
    .btn-group {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .btn-group .btn {
        padding: 6px 10px;
    }
    
    /* Page header buttons */
    .page-header .d-flex {
        width: 100%;
        flex-direction: column;
    }
    
    .page-header .d-flex .btn {
        width: 100%;
        margin-bottom: 8px;
    }
    
    /* Table header */
    .table-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    /* Dropdown menus */
    .dropdown-menu {
        max-width: 90vw;
    }
}

/* ==================== RESPONSIVE - SMALL MOBILE ==================== */
@media (max-width: 480px) {
    .login-box {
        padding: 25px 20px;
    }
    
    .login-header h1 {
        font-size: 20px;
    }
    
    .header-title {
        font-size: 14px;
        max-width: 100px;
    }
    
    .location-selector {
        padding: 6px 8px;
        gap: 4px;
    }
    
    .location-selector i {
        font-size: 12px;
    }
    
    .location-selector select {
        font-size: 11px;
        max-width: 90px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        flex-direction: row;
        text-align: left;
    }
    
    .page-title {
        font-size: 18px;
    }
    
    .table {
        min-width: 500px;
    }
    
    /* Even smaller buttons */
    .btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .btn i {
        font-size: 14px;
    }
    
    /* Form controls */
    .form-control, .form-select {
        padding: 8px 12px;
        font-size: 14px;
    }
    
    /* Modal adjustments */
    .modal-header {
        padding: 12px 15px;
    }
    
    .modal-title {
        font-size: 16px;
    }
    
    .modal-footer {
        padding: 12px 15px;
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
        margin: 4px 0;
    }
}

/* ==================== UTILITIES ==================== */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.d-grid { display: grid !important; }

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--secondary); }

.mb-0 { margin-bottom: 0 !important; }
.mb-2 { margin-bottom: 8px !important; }
.mb-3 { margin-bottom: 16px !important; }
.mb-4 { margin-bottom: 24px !important; }

.mt-2 { margin-top: 8px !important; }
.mt-3 { margin-top: 16px !important; }

.me-2 { margin-right: 8px !important; }
.ms-2 { margin-left: 8px !important; }

.p-0 { padding: 0 !important; }
.py-4 { padding-top: 24px !important; padding-bottom: 24px !important; }

.gap-2 { gap: 8px !important; }
.gap-3 { gap: 16px !important; }

.w-100 { width: 100% !important; }

.flex-wrap { flex-wrap: wrap !important; }
.align-items-center { align-items: center !important; }
.justify-content-between { justify-content: space-between !important; }


/* ==================== TAB BUTTONS FIX ==================== */
/* Fix for white text on white background in nav-tabs */
.nav-tabs {
    border-bottom: 2px solid #e2e8f0;
}

.nav-tabs .nav-link {
    color: #64748b !important;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 12px 20px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.nav-tabs .nav-link:hover {
    color: var(--primary) !important;
    border-bottom-color: var(--primary-light);
    background: rgba(79, 70, 229, 0.05);
}

.nav-tabs .nav-link.active {
    color: var(--primary) !important;
    background: white;
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.nav-tabs .nav-link i {
    margin-right: 6px;
}
