/* Prevent body/html from scrolling */
html, body {
    height: 100%;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4f46e5;
    --secondary-color: #7c3aed;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --dark-bg: #1f2937;
    --sidebar-width: 260px;
    --header-height: 70px;
    --bottom-nav-height: 70px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f3f4f6;
    color: #1f2937;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Warning banner adjustments */
.warning-banner .close-warning {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    margin-left: auto;
    opacity: 0.8;
}

.warning-banner .close-warning:hover {
    opacity: 1;
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width);
    background: var(--dark-bg);
    color: white;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 1000;
    transition: transform 0.3s ease;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #374151;
}

.sidebar-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.close-sidebar {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    display: none;
}

.nav-menu {
    list-style: none;
    padding: 20px 0;
}

.nav-item {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 0.3s;
    color: #9ca3af;
}

.nav-item:hover {
    background: #374151;
    color: white;
}

.nav-item.active {
    background: var(--primary-color);
    color: white;
}

.nav-item .material-icons {
    font-size: 20px;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.top-bar {
    height: var(--header-height);
    background: white;
    padding: 0 30px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.menu-toggle {
    background: none;
    border: none;
    cursor: pointer;
    display: none;
}

.menu-toggle .material-icons {
    font-size: 28px;
    color: var(--dark-bg);
}

#pageTitle {
    font-size: 1.5rem;
    font-weight: 600;
}

.content-wrapper {
    padding: 30px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Dashboard Cards */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
    flex-shrink: 0;
}

.card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.card-title {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--dark-bg);
}

/* Tables */
.table-container {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow-x: auto;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* Recent Payments specific */
.dashboard-cards + .table-container {
    max-height: 350px;
    min-height: 200px;
}

#recentPayments {
    flex: 1;
    overflow-y: auto;
}

/* Sticky header inside scrollable table */
.table-container table {
    width: 100%;
    border-collapse: collapse;
}

.table-container table thead {
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

.table-container table thead th {
    background: #f9fafb;
    position: sticky;
    top: 0;
    box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.1);
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
    flex-shrink: 0;
}

.search-box {
    display: flex;
    gap: 10px;
    flex: 1;
    max-width: 100%;
    flex-wrap: wrap;
}

.search-box input {
    flex: 1;
    min-width: 200px;
    padding: 10px 15px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--secondary-color);
}

.btn-secondary {
    background: #e5e7eb;
    color: var(--dark-bg);
}

.btn-secondary:hover {
    background: #d1d5db;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

th {
    background: #f9fafb;
    font-weight: 600;
    color: #4b5563;
    cursor: pointer;
    user-select: none;
}

th:hover {
    background: #f3f4f6;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background 0.3s;
}

.icon-btn:hover {
    background: #f3f4f6;
}

.icon-btn.edit {
    color: var(--primary-color);
}

.icon-btn.delete {
    color: var(--danger-color);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.close-modal {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #4b5563;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Bottom Navigation */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: white;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 999;
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    transition: color 0.3s;
}

.bottom-nav-item.active {
    color: var(--primary-color);
}

.bottom-nav-item .material-icons {
    font-size: 24px;
}

.bottom-nav-item span {
    font-size: 12px;
}

/* Filter Section */
.filter-section {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.filter-section select {
    padding: 10px 15px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    min-width: 150px;
}

/* Report Section */
.report-section {
    margin-bottom: 25px;
}

.report-section h4 {
    margin-bottom: 15px;
    color: var(--dark-bg);
    font-size: 1.1rem;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 8px;
}

.report-section p {
    margin-bottom: 8px;
}

.report-section table {
    margin-top: 10px;
}

/* Pagination Styles */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding: 15px 0;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.pagination-info {
    color: #6b7280;
    font-size: 14px;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.page-size-select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

.page-buttons {
    display: flex;
    gap: 5px;
}

.btn-page {
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border: 1px solid #e5e7eb;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-page:hover:not(:disabled) {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.btn-page.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-page:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-page .material-icons {
    font-size: 20px;
}

.no-data {
    text-align: center;
    padding: 40px;
    color: #6b7280;
    font-size: 14px;
}

/* Date range filter styles */
#customDateRange {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

#customDateRange input {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
}

.filter-section select, 
.filter-section input {
    min-width: 130px;
}

@media (max-width: 768px) {
    #customDateRange {
        width: 100%;
    }
    
    #customDateRange input {
        flex: 1;
    }
}

/* Spinning animation for loading states */
.spinning {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Disabled button state during processing */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Loading button style */
.btn-loading {
    position: relative;
    pointer-events: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    .content-wrapper {
        padding: 15px;
        padding-bottom: calc(var(--bottom-nav-height) + 15px);
    }
    
    .dashboard-cards + .table-container {
        max-height: none;
        margin-bottom: 10px;
    }
    
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .menu-toggle {
        display: block;
    }
    
    .close-sidebar {
        display: block;
    }
    
    .bottom-nav {
        display: flex;
    }
    
    .dashboard-cards {
        grid-template-columns: 1fr;
    }
    
    .table-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box {
        max-width: none;
    }
    
    /* Mobile: Icon-only buttons */
    .btn .btn-text {
        display: none;
    }
    
    .btn {
        padding: 10px 12px;
    }
    
    .btn .material-icons {
        margin: 0;
    }
    
    /* Mobile pagination */
    .pagination-container {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .pagination-controls {
        justify-content: space-between;
        flex-wrap: wrap;
    }
    
    .page-buttons {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    /* Mobile tables */
    .table-container {
        padding: 15px;
    }
    
    th, td {
        padding: 8px;
        font-size: 13px;
    }
    
    .modal-content {
        padding: 20px;
        width: 95%;
    }
}

/* For desktop, ensure nothing is covered */
@media (min-width: 769px) {
    .content-wrapper {
        padding-bottom: 30px;
    }
}

/* Print Styles */
@media print {
    .sidebar, .top-bar, .bottom-nav, .btn, .action-buttons, .pagination-container {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .modal {
        position: static;
        display: block;
    }
    
    .table-container {
        max-height: none;
        overflow: visible;
    }
    
    .content-wrapper {
        height: auto;
        overflow: visible;
    }
}