/**
 * MIQT System Styles
 * Minhaj Institute of Qirat & Tajweed
 */

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2c5f2d;
    --secondary-color: #1e7e34;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --border-color: #dee2e6;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 72px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    background-color: #f4f6f9;
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #2c5f2d 0%, #1e7e34 100%);
}

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

.login-box {
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, #2c5f2d 0%, #1e7e34 100%);
    color: white;
    padding: 40px 30px;
    text-align: center;
}

.login-header i {
    font-size: 48px;
    margin-bottom: 15px;
}

.login-header h1 {
    font-size: 28px;
    margin-bottom: 5px;
}

.login-header p {
    font-size: 14px;
    opacity: 0.9;
}

.login-form {
    padding: 30px;
}

.login-footer {
    background: #f8f9fa;
    padding: 20px 30px;
    text-align: center;
    border-top: 1px solid #dee2e6;
}

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #2c5f2d 0%, #1e7e34 100%);
    color: white;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1000;
    transition: width 0.3s ease, margin-left 0.3s ease;
    left: 0;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed.hovering {
    width: var(--sidebar-width);
}

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

.sidebar-header h3 {
    font-size: 22px;
    margin-bottom: 10px;
}

.sidebar-menu {
    list-style: none;
    padding: 15px 0;
}

.sidebar-menu li {
    margin: 5px 0;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: white;
    text-decoration: none;
    transition: all 0.3s;
    white-space: nowrap;
}

.sidebar-menu a:hover {
    background: rgba(255,255,255,0.1);
    padding-left: 30px;
}

.sidebar-menu a.active {
    background: rgba(255,255,255,0.2);
    border-left: 4px solid white;
    padding-left: 26px;
    font-weight: 600;
}

.sidebar-menu a i {
    margin-right: 12px;
    width: 20px;
    text-align: center;
}

.sidebar-menu .submenu {
    list-style: none;
    padding-left: 40px;
    display: none;
}

.sidebar-menu .has-dropdown.active + .submenu {
    display: block;
}

.sidebar-menu .submenu a {
    padding: 10px 20px;
    font-size: 13px;
}

.sidebar.collapsed .sidebar-header h3,
.sidebar.collapsed .sidebar-header p {
    display: none;
}

.sidebar.collapsed .sidebar-menu a {
    justify-content: center;
    padding: 12px 0;
    overflow: hidden;
    font-size: 0; /* hide text labels */
}

.sidebar.collapsed .sidebar-menu a i {
    margin-right: 0;
    font-size: 18px; /* keep icons visible */
}

.sidebar.collapsed .submenu {
    display: none; /* keep all submenus hidden while collapsed */
}

/* When collapsed but hovering (expanded visually), allow dropdowns to open */
.sidebar.collapsed.hovering .has-dropdown.active + .submenu {
    display: block;
}

.sidebar.collapsed.hovering .sidebar-header h3,
.sidebar.collapsed.hovering .sidebar-header p {
    display: block;
}

.sidebar.collapsed.hovering .sidebar-menu a {
    justify-content: flex-start;
    padding: 12px 20px;
    font-size: 14px; /* restore labels on hover */
}

.sidebar.collapsed.hovering .sidebar-menu a i {
    margin-right: 12px;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: all 0.3s;
}

.main-content.expanded {
    margin-left: var(--sidebar-collapsed-width);
    width: calc(100% - var(--sidebar-collapsed-width));
}

.main-content.expanded.hovering {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
}

.topbar {
    background: white;
    padding: 15px 30px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toggle-btn {
    font-size: 24px;
    cursor: pointer;
    color: var(--dark-color);
    padding: 5px 10px;
    transition: all 0.3s;
}

.toggle-btn:hover {
    color: var(--primary-color);
    transform: scale(1.1);
}

.user-info {
    font-size: 13px;
    color: #666;
}

.content {
    flex: 1;
    padding: 30px;
}

.footer {
    background: white;
    padding: 20px 30px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 13px;
    color: #666;
}

/* Page Title */
.page-title {
    font-size: 28px;
    margin-bottom: 10px;
    color: var(--dark-color);
}

.subtitle {
    font-size: 14px;
    color: #666;
    margin-bottom: 30px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 10px;
    padding: 25px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    border-left: 4px solid var(--primary-color);
}

.stat-card.stat-primary { border-left-color: var(--primary-color); }
.stat-card.stat-success { border-left-color: var(--success-color); }
.stat-card.stat-info { border-left-color: var(--info-color); }
.stat-card.stat-warning { border-left-color: var(--warning-color); }

.stat-icon {
    font-size: 48px;
    margin-right: 20px;
    opacity: 0.8;
}

.stat-card.stat-primary .stat-icon { color: var(--primary-color); }
.stat-card.stat-success .stat-icon { color: var(--success-color); }
.stat-card.stat-info .stat-icon { color: var(--info-color); }
.stat-card.stat-warning .stat-icon { color: var(--warning-color); }

.stat-info h3 {
    font-size: 32px;
    margin-bottom: 5px;
}

.stat-info p {
    font-size: 14px;
    color: #666;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.dashboard-card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    overflow: hidden;
}

.card-header {
    background: #f8f9fa;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    font-size: 18px;
    color: var(--dark-color);
}

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

.card-body {
    padding: 20px;
}

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

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

.form-control {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.3s;
}

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

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

select.form-control {
    cursor: pointer;
}

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

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s;
    text-align: center;
}

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

.btn-primary:hover {
    background: var(--secondary-color);
}

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

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

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

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

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

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

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead {
    background: #f8f9fa;
}

.table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--dark-color);
    border-bottom: 2px solid var(--border-color);
}

.table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

.table tbody tr:hover {
    background: #f8f9fa;
}

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid var(--success-color);
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid var(--danger-color);
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border-left: 4px solid var(--warning-color);
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border-left: 4px solid var(--info-color);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success { background: var(--success-color); color: white; }
.badge-danger { background: var(--danger-color); color: white; }
.badge-warning { background: var(--warning-color); color: #000; }
.badge-info { background: var(--info-color); color: white; }
.badge-primary { background: var(--primary-color); color: white; }

/* Activity List */
.activity-list {
    max-height: 400px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    margin-right: 15px;
    color: var(--primary-color);
}

.activity-details {
    flex: 1;
}

.activity-text {
    margin-bottom: 5px;
}

.activity-time {
    font-size: 12px;
    color: #999;
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-muted { color: #999; }
.mb-20 { margin-bottom: 20px; }
.mt-20 { margin-top: 20px; }

/* Pagination */
.pagination {
    display: flex;
    list-style: none;
    justify-content: center;
    margin-top: 20px;
}

.pagination li {
    margin: 0 5px;
}

.pagination a {
    display: block;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    color: var(--dark-color);
    text-decoration: none;
    transition: all 0.3s;
}

.pagination a:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.pagination .active a {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        margin-left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
    }

    .main-content.expanded {
        margin-left: var(--sidebar-collapsed-width);
        width: calc(100% - var(--sidebar-collapsed-width));
    }

    .stats-grid,
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .topbar,
    .footer,
    .btn {
        display: none;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }
}
.sidebar.collapsed .submenu a.active {
    background: transparent;
    border-left: none;
    font-weight: 500;
    padding-left: 0;
}

/* Keep top-level active highlight even when collapsed */
.sidebar.collapsed .sidebar-menu > li > a.active {
    background: rgba(255,255,255,0.2);
    border-left: 4px solid white;
}
