@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;700&display=swap');
@import 'variables.css';

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    /* Prevent horizontal scroll from mobile sidebar */
}

/* --- Layout Styles (Moved from header.php) --- */
.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
    /* overflow-x: hidden; REMOVED to fix sticky sidebar */
}

.main-content {
    flex: 1;
    padding: 2rem;
    background-color: var(--bg-body);
    transition: var(--transition);
    width: 100%;
}

/* Sidebar Styling */
.sidebar {
    width: 250px;
    background: var(--primary-dark);
    color: white;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease-in-out;
    flex-shrink: 0;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 1000;
    overflow-y: auto;
    /* Enable scrolling for tall menus */
}

/* Header/Navbar Styling */
.top-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: white;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
    border-radius: var(--border-radius);
}

.toggle-menu i {
    cursor: pointer;
    transition: color 0.3s;
}

/* --- Responsive & Mobile Styles --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s;
}

.payment-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 25px;
}

@media (max-width: 900px) {
    .payment-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        right: -260px;
        top: 0;
        height: 100vh;
        box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    }

    .sidebar.active {
        right: 0;
    }

    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }

    .main-content {
        padding: 1rem;
    }

    .top-navbar {
        padding: 1rem;
    }

    .stat-cards-grid {
        grid-template-columns: 1fr !important;
    }
}

/* --- Responsive Utility Classes --- */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.grid-auto {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

@media (max-width: 1024px) {

    .grid-4,
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {

    .grid-4,
    .grid-3,
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.card {
    background: var(--bg-card);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border-right: 5px solid var(--primary-color);
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
}

/* Desktop Collapse Behavior */
@media (min-width: 769px) {
    .sidebar.collapsed {
        width: 0;
        overflow: hidden;
        padding: 0;
        margin-left: 0;
    }
}

/* --- Auth Page Layout --- */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: url('../images/water-bg.jpg') no-repeat center center/cover;
    /* Default fallback if logo logic was removed/changed */
    position: relative;
}

/* User specifically asked for logo bg before, restoring it cautiously or using clean backup */
/* Actually, let's keep the user's latest 'logo.png' preference but handled better */
.auth-container {
    background: url('../images/logo.png') no-repeat center center/cover;
    /* Wait, path is relative to css file. assets/css/main.css -> ../images/logo.png is assets/images/logo.png. Correct. */
}

.auth-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 60, 100, 0.85);
    /* Darker overlay to make text readable */
    backdrop-filter: blur(5px);
}

.auth-card {
    position: relative;
    background: var(--bg-card);
    padding: 3rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 450px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: slideUp 0.5s ease-out;
    margin: 20px;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.auth-logo {
    width: 120px;
    height: 120px;
    margin-bottom: 1.5rem;
    object-fit: cover;
    background: white;
    border-radius: 50%;
    padding: 5px;
    box-shadow: var(--shadow-md);
    border: 2px solid #e0e0e0;
}

.auth-title {
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

/* Form Elements */
.form-group {
    margin-bottom: 1.5rem;
    text-align: right;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    font-family: var(--font-family);
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 119, 182, 0.1);
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    background: linear-gradient(135deg, #023e8a 0%, #0077b6 100%);
}

/* --- Modern Alert Messages --- */
.alert {
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 25px;
    font-size: 1rem;
    font-weight: 600;
    position: relative;
    border: 1px solid transparent;
    /* Fallback */
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    animation: slideDownFade 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    overflow: hidden;
}

/* Animation */
@keyframes slideDownFade {
    0% {
        transform: translateY(-20px);
        opacity: 0;
    }

    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Icon Integration via Pseudo-element */
.alert::before {
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    font-size: 1.4rem;
    opacity: 0.9;
}

/* Success Style */
.alert-success {
    background-color: #f0fdf4;
    /* Green-50 */
    color: #15803d;
    /* Green-700 */
    border: 1px solid #bbf7d0;
    border-right: 6px solid #22c55e;
    /* Green-500 */
}

.alert-success::before {
    content: "\f00c";
    /* fa-check */
    color: #22c55e;
}

/* Danger Style */
.alert-danger {
    background-color: #fef2f2;
    /* Red-50 */
    color: #b91c1c;
    /* Red-700 */
    border: 1px solid #fecaca;
    border-right: 6px solid #ef4444;
    /* Red-500 */
}

.alert-danger::before {
    content: "\f06a";
    /* fa-exclamation-circle */
    color: #ef4444;
}

/* Warning Style */
.alert-warning {
    background-color: #fffbeb;
    /* Amber-50 */
    color: #b45309;
    /* Amber-700 */
    border: 1px solid #fde68a;
    border-right: 6px solid #f59e0b;
    /* Amber-500 */
}

.alert-warning::before {
    content: "\f071";
    /* fa-exclamation-triangle */
    color: #f59e0b;
}

/* Info Style */
.alert-info {
    background-color: #eff6ff;
    /* Blue-50 */
    color: #1d4ed8;
    /* Blue-700 */
    border: 1px solid #bfdbfe;
    border-right: 6px solid #3b82f6;
    /* Blue-500 */
}

.alert-info::before {
    content: "\f05a";
    /* fa-info-circle */
    color: #3b82f6;
}

.footer-credits {
    margin-top: 2rem;
    font-size: 0.8rem;
    color: #ccc;
}

/* --- Filter Group Semented Control --- */
.filter-container {
    background: white;
    padding: 10px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    display: inline-flex;
    background-color: #f1f3f5;
    padding: 5px;
    border-radius: 50px;
    /* Pillow shape */
}

.filter-btn {
    text-decoration: none;
    color: #555;
    padding: 8px 20px;
    border-radius: 50px;
    transition: all 0.3s ease;
    font-weight: 600;
    font-size: 0.95rem;
    margin: 0 2px;
}

.filter-btn:hover {
    color: var(--primary-dark);
    background-color: rgba(0, 0, 0, 0.05);
}

.filter-btn.active {
    background-color: white;
    color: var(--primary-color);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Specific colors for specific states when active */
.filter-btn.active[data-filter="unpaid"] {
    color: #e74c3c;
}

.filter-btn.active[data-filter="paid"] {
    color: #27ae60;
}