/* School Fee Management System - Main Stylesheet */
/* Modern, Sleek, Responsive Design */

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --secondary: #06b6d4;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --dark: #1e293b;
    --gray: #64748b;
    --gray-light: #94a3b8;
    --gray-lighter: #e2e8f0;
    --light: #f8fafc;
    --white: #ffffff;
    --sidebar-width: 260px;
    --header-height: 70px;
    --border-radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--dark);
    background: var(--light);
}

/* Login Page Styles */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-box {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 40px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header .logo {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.login-header .logo i {
    font-size: 36px;
    color: var(--white);
}

.login-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 5px;
}

.login-header p {
    color: var(--gray);
    font-size: 14px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--dark);
}

.login-form label i {
    margin-right: 8px;
    color: var(--primary);
}

.login-form input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--gray-lighter);
    border-radius: 8px;
    font-size: 15px;
    transition: var(--transition);
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary);
}

.password-input {
    position: relative;
}

.password-input input {
    padding-right: 50px;
}

.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--gray);
    cursor: pointer;
    padding: 5px;
}

.toggle-password:hover {
    color: var(--primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn i {
    margin-right: 8px;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--gray-lighter);
    color: var(--dark);
}

.btn-secondary:hover {
    background: var(--gray-light);
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-warning {
    background: var(--warning);
    color: var(--white);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-xs {
    padding: 5px 10px;
    font-size: 12px;
}

/* Alert Styles */
.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid var(--success);
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid var(--danger);
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border-left: 4px solid var(--warning);
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border-left: 4px solid var(--info);
}

.login-footer {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-lighter);
}

.login-footer p {
    color: var(--gray);
    font-size: 13px;
    margin-bottom: 10px;
}

.login-footer .branding {
    color: var(--primary);
    font-weight: 600;
}

/* Main Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--dark);
    color: var(--white);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-header {
    padding: 25px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header .logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-header .logo-icon {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-header .logo-icon i {
    font-size: 22px;
}

.sidebar-header .logo-text {
    font-size: 18px;
    font-weight: 700;
}

.sidebar-header .logo-text span {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: var(--gray-light);
}

.sidebar-menu {
    padding: 20px 0;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: var(--transition);
    border-left: 4px solid transparent;
}

.menu-item:hover,
.menu-item.active {
    background: rgba(255,255,255,0.05);
    color: var(--white);
    border-left-color: var(--primary);
}

.menu-item i {
    width: 24px;
    margin-right: 12px;
    font-size: 16px;
}

.menu-section {
    padding: 10px 20px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gray);
    margin-top: 10px;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: auto;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-details {
    flex: 1;
}

.user-details .name {
    font-weight: 600;
    font-size: 14px;
}

.user-details .role {
    font-size: 12px;
    color: var(--gray-light);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

/* Header */
.header {
    height: var(--header-height);
    background: var(--white);
    padding: 0 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left h2 {
    font-size: 20px;
    font-weight: 600;
}

.header-left p {
    font-size: 13px;
    color: var(--gray);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--light);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--dark);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.header-btn:hover {
    background: var(--gray-lighter);
}

.header-btn .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger);
    color: var(--white);
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
}

/* Content Area */
.content {
    padding: 30px;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.stats-grid .stat-card {
    min-width: 0;
}

.stat-card {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.stat-icon.blue { background: #dbeafe; color: var(--primary); }
.stat-icon.green { background: #d1fae5; color: var(--success); }
.stat-icon.orange { background: #fef3c7; color: var(--warning); }
.stat-icon.red { background: #fee2e2; color: var(--danger); }
.stat-icon.purple { background: #e0e7ff; color: #6366f1; }
.stat-icon.cyan { background: #cffafe; color: var(--secondary); }

.stat-info h3 {
    font-size: 22px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 2px;
    line-height: 1.2;
}

.stat-info p {
    font-size: 12px;
    color: var(--gray);
    font-weight: 500;
    line-height: 1.3;
}

.stat-change {
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}

.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-lighter);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.card-header h3 i {
    margin-right: 10px;
    color: var(--primary);
}

.card-body {
    padding: 24px;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 14px 16px;
    text-align: left;
}

.data-table th {
    background: var(--light);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray);
    border-bottom: 2px solid var(--gray-lighter);
}

.data-table td {
    border-bottom: 1px solid var(--gray-lighter);
    font-size: 14px;
}

.data-table tr:hover td {
    background: var(--light);
}

.data-table tr:last-child td {
    border-bottom: none;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.paid { background: #d1fae5; color: #065f46; }
.status-badge.unpaid { background: #fee2e2; color: #991b1b; }
.status-badge.partial { background: #fef3c7; color: #92400e; }
.status-badge.waived { background: #e0e7ff; color: #3730a3; }
.status-badge.active { background: #d1fae5; color: #065f46; }
.status-badge.inactive { background: #fee2e2; color: #991b1b; }

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--dark);
}

.form-group label .required {
    color: var(--danger);
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--gray-lighter);
    border-radius: 8px;
    font-size: 14px;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

.form-control::placeholder {
    color: var(--gray-light);
}

select.form-control {
    cursor: pointer;
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

/* Search and Filter */
.search-filter {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 250px;
}

.search-box input {
    width: 100%;
    padding: 12px 14px 12px 44px;
    border: 2px solid var(--gray-lighter);
    border-radius: 8px;
    font-size: 14px;
}

.search-box i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray);
}

/* Action Buttons in Tables */
.action-btns {
    display: flex;
    gap: 6px;
}

.action-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    color: var(--white);
}

.action-btn.view { background: var(--info); }
.action-btn.edit { background: var(--warning); }
.action-btn.delete { background: var(--danger); }
.action-btn.print { background: var(--success); }

.action-btn:hover {
    transform: scale(1.1);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--white);
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: var(--transition);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-lighter);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray);
    cursor: pointer;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-lighter);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--gray-lighter);
    margin-bottom: 24px;
}

.tab {
    padding: 12px 20px;
    font-weight: 500;
    color: var(--gray);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
}

.tab:hover {
    color: var(--primary);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Fee Slip Styles */
.fee-slip {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 30px;
    border: 2px solid var(--gray-lighter);
}

.fee-slip-header {
    text-align: center;
    border-bottom: 2px solid var(--dark);
    padding-bottom: 20px;
    margin-bottom: 20px;
}

.fee-slip-header h2 {
    font-size: 24px;
    margin-bottom: 5px;
}

.fee-slip-info {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.fee-slip-info .info-row {
    display: flex;
}

.fee-slip-info .label {
    font-weight: 600;
    min-width: 120px;
}

.fee-components-table {
    width: 100%;
    margin: 20px 0;
}

.fee-components-table th,
.fee-components-table td {
    padding: 10px;
    border: 1px solid var(--gray-lighter);
    text-align: left;
}

.fee-components-table th {
    background: var(--light);
    font-weight: 600;
}

.fee-summary {
    margin-top: 20px;
    border-top: 2px solid var(--dark);
    padding-top: 15px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
}

.summary-row.total {
    font-size: 18px;
    font-weight: 700;
    border-top: 1px solid var(--gray-lighter);
    margin-top: 10px;
    padding-top: 15px;
}

/* Mobile Toggle Button - Hidden by default on desktop */
.mobile-toggle {
    display: none;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--dark);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-right: 10px;
    padding: 0;
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .mobile-toggle {
        display: flex;
    }
}

@media (max-width: 768px) {
    .content {
        padding: 15px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .search-filter {
        flex-direction: column;
    }
    
    .search-box {
        min-width: 100%;
    }
}

/* Mobile Sidebar Close Button - visible on all mobile sizes */
.sidebar-close {
    display: none;
    position: absolute;
    top: 15px;
    right: 15px;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    color: white;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    z-index: 100;
}

.sidebar-close:hover {
    background: rgba(255,255,255,0.1);
    border-color: white;
}

/* Small screens - 360px and below */
@media (max-width: 360px) {
    html, body {
        overflow-x: hidden;
        max-width: 360px;
    }
    
    /* Mobile toggle - show on mobile */
    .mobile-toggle {
        display: flex !important;
    }
    
    /* Sidebar close button - show on mobile */
    .sidebar-close {
        display: flex;
    }
    
    .app-layout {
        width: 100%;
        max-width: 360px;
        overflow-x: hidden;
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
        max-width: 360px;
        overflow-x: hidden;
    }
    
    .content {
        padding: 10px;
        width: 100%;
        max-width: 360px;
        box-sizing: border-box;
    }
    
    /* Header fixes for mobile */
    .header {
        padding: 0 15px;
        height: auto;
        min-height: 60px;
        flex-wrap: wrap;
    }
    
    .header-left {
        flex: 1;
        min-width: 0;
        padding-right: 10px;
    }
    
    .header-left h2 {
        font-size: 16px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .header-left p {
        font-size: 11px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .header-right {
        gap: 8px;
        flex-shrink: 0;
    }
    
    .header-right > div {
        font-size: 12px !important;
        display: none;
    }
    
    .header-btn {
        width: 36px;
        height: 36px;
    }
    
    .card {
        width: 100%;
        max-width: 340px;
        margin-left: auto;
        margin-right: auto;
        box-sizing: border-box;
    }
    
    .card-header {
        padding: 15px;
    }
    
    .card-body {
        padding: 15px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .stat-card {
        padding: 15px;
    }
    
    .btn {
        padding: 10px 15px;
        font-size: 14px;
    }
    
    h1 {
        font-size: 20px;
    }
    
    h2 {
        font-size: 18px;
    }
    
    h3 {
        font-size: 16px;
    }
    
    .data-table th,
    .data-table td {
        padding: 10px;
        font-size: 13px;
    }
    
    .form-control {
        padding: 10px 12px;
    }
    
    .search-box {
        min-width: 100%;
    }
    
    /* Dashboard grids - force single column on mobile */
    .card-body > div[style*="grid-template-columns"],
    .content > div[style*="grid-template-columns"],
    div[style*="grid-template-columns: 2fr 1fr"],
    div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
    
    /* Stats dashboard */
    .stats-dashboard .stats-row {
        grid-template-columns: 1fr !important;
    }
    
    /* Make cards full width in grids */
    .content > div[style*="grid-template-columns"] > .card {
        width: 100% !important;
        min-width: 100% !important;
    }
    
    /* Table container fix */
    .table-container {
        overflow-x: auto;
        max-width: 100%;
    }
}

/* Hide sidebar close button on desktop */
@media (min-width: 1025px) {
    .sidebar-close {
        display: none !important;
    }
}

/* Chart Styles */
.chart-card {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.chart-card .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-lighter);
    background: linear-gradient(135deg, var(--white) 0%, var(--light) 100%);
}

.chart-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--gray);
    font-weight: 500;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.chart-container {
    position: relative;
    width: 100%;
    height: 320px;
    padding: 10px;
}

.chart-container canvas {
    width: 100%;
    height: 100%;
}

/* Charts placeholder (fallback) */
.chart-container:empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray);
}

/* Print Styles */
@media print {
    .sidebar,
    .header,
    .no-print {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .fee-slip {
        border: none;
        padding: 0;
    }
}
