/* Custom CSS for e-Rapor SMA */

:root {
    --bs-primary: #435ebe;
    --bs-secondary: #6c757d;
    --bs-success: #198754;
    --bs-danger: #dc3545;
    --bs-warning: #ffc107;
    --bs-info: #0dcaf0;
    --sidebar-width: 260px;
}

/* Body */
body {
    font-family: 'Nunito', sans-serif;
    background-color: #f8f9fa;
}

/* Sidebar */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: #fff;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
    z-index: 10;
    transition: all 0.3s ease;
}

.sidebar-wrapper {
    height: 100%;
    overflow-y: auto;
}

.sidebar-header {
    padding: 2rem 1.5rem 1.5rem;
    border-bottom: 1px solid #dee2e6;
}

.sidebar-header .logo img {
    height: 36px;
}

.sidebar-menu {
    padding: 1rem 0;
}

.menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-title {
    padding: 1rem 1.5rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #6c757d;
    letter-spacing: 0.5px;
}

.sidebar-item {
    margin: 0.25rem 0.75rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: #25396f;
    text-decoration: none;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
}

.sidebar-link i {
    font-size: 1.2rem;
    margin-right: 0.75rem;
    width: 24px;
    text-align: center;
}

.sidebar-link:hover {
    background-color: #f8f9fa;
    color: var(--bs-primary);
}

.sidebar-item.active .sidebar-link {
    background-color: var(--bs-primary);
    color: #fff;
}

/* Main Content */
#main {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: 2rem;
}

#main header {
    display: none;
}

.page-heading {
    margin-bottom: 2rem;
}

.page-heading h3 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #25396f;
    margin: 0;
}

.page-content {
    margin-bottom: 3rem;
}

/* Cards */
.card {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.05);
    margin-bottom: 1.5rem;
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid #dee2e6;
    padding: 1.25rem 1.5rem;
}

.card-header h4 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #25396f;
}

.card-body {
    padding: 1.5rem;
}

/* Statistics Cards */
.stats-icon {
    width: 50px;
    height: 50px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #fff;
}

.stats-icon.purple {
    background-color: #6f42c1;
}

.stats-icon.blue {
    background-color: #0d6efd;
}

.stats-icon.green {
    background-color: #198754;
}

.stats-icon.red {
    background-color: #dc3545;
}

.font-extrabold {
    font-weight: 800;
}

.font-bold {
    font-weight: 700;
}

.font-semibold {
    font-weight: 600;
}

/* Avatar */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    display: inline-block;
}

.avatar.avatar-xl {
    width: 64px;
    height: 64px;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Footer */
footer {
    padding: 1.5rem 0;
    border-top: 1px solid #dee2e6;
    margin-top: 3rem;
}

footer .footer {
    font-size: 0.875rem;
    color: #6c757d;
}

/* Form Groups with Icons */
.form-group.position-relative.has-icon-left {
    position: relative;
}

.form-group .form-control {
    padding-left: 2.5rem;
}

.form-control-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    pointer-events: none;
}

/* Buttons */
.btn {
    border-radius: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-weight: 600;
}

.btn-block {
    width: 100%;
}

/* List Group */
.list-group-item {
    border: none;
    border-radius: 0.5rem !important;
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
}

.list-group-item:hover {
    background-color: #f8f9fa;
    transform: translateX(5px);
}

/* Sidebar Overlay/Backdrop */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* Responsive */
@media (max-width: 1200px) {
    #sidebar {
        left: -var(--sidebar-width);
        z-index: 1000;
    }

    #sidebar.active {
        left: 0;
        box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);
    }

    /* Fix mobile sidebar scroll */
    .sidebar-wrapper {
        height: 100%;
        max-height: 100vh;
        max-height: -webkit-fill-available;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .sidebar-menu {
        padding-bottom: 80px;
    }

    #main {
        margin-left: 0;
        padding: 1.5rem;
    }

    #main header {
        display: block;
        margin-bottom: 1.5rem;
    }

    .burger-btn {
        font-size: 1.5rem;
        color: #25396f;
        text-decoration: none;
        transition: transform 0.3s ease;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border-radius: 0.5rem;
    }

    .burger-btn:hover {
        background-color: #f8f9fa;
        transform: scale(1.05);
    }

    .burger-btn:active {
        background-color: #e9ecef;
    }

    .page-heading {
        margin-bottom: 1.5rem;
    }

    .page-heading h3 {
        font-size: 1.5rem;
    }

    /* Prevent body scroll when sidebar is open */
    body.sidebar-open {
        overflow: hidden;
    }
}

/* Tablet and below */
@media (max-width: 992px) {
    #main {
        padding: 1.25rem;
    }

    .page-heading h3 {
        font-size: 1.4rem;
    }

    .card {
        margin-bottom: 1rem;
    }

    .card-header {
        padding: 1rem 1.25rem;
    }

    .card-header h4 {
        font-size: 1.1rem;
    }

    .card-body {
        padding: 1.25rem;
    }

    .sidebar-header {
        padding: 1.5rem 1.25rem 1.25rem;
    }

    .sidebar-header .logo h4 {
        font-size: 1.25rem;
    }

    /* Make sidebar menu more compact */
    .sidebar-item {
        margin: 0.2rem 0.5rem;
    }

    .sidebar-link {
        padding: 0.65rem 0.85rem;
        font-size: 0.95rem;
    }

    .sidebar-link i {
        font-size: 1.1rem;
        margin-right: 0.65rem;
    }

    .sidebar-title {
        padding: 0.85rem 1rem 0.4rem;
        font-size: 0.7rem;
    }
}

/* Mobile landscape and below */
@media (max-width: 768px) {
    #main {
        padding: 1rem;
    }

    #main header {
        margin-bottom: 1rem;
        padding-bottom: 0.75rem;
        border-bottom: 1px solid #dee2e6;
    }

    body.theme-dark #main header {
        border-bottom-color: #3e4259;
    }

    .page-heading {
        margin-bottom: 1rem;
    }

    .page-heading h3 {
        font-size: 1.3rem;
        line-height: 1.3;
    }

    .card {
        border-radius: 0.5rem;
        margin-bottom: 1rem;
    }

    .card-header {
        padding: 0.85rem 1rem;
    }

    .card-header h4 {
        font-size: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    /* Sidebar adjustments for smaller screens */
    :root {
        --sidebar-width: 280px;
    }

    #sidebar {
        width: 280px;
        max-width: 85vw;
    }

    .sidebar-header {
        padding: 1.25rem 1rem 1rem;
    }

    .sidebar-header .logo h4 {
        font-size: 1.2rem;
    }

    .sidebar-header .theme-toggle {
        gap: 0.35rem;
    }

    .sidebar-header .theme-toggle svg {
        width: 18px;
        height: 18px;
    }

    .sidebar-item {
        margin: 0.15rem 0.5rem;
    }

    .sidebar-link {
        padding: 0.6rem 0.75rem;
        font-size: 0.9rem;
    }

    .sidebar-link i {
        font-size: 1rem;
        margin-right: 0.6rem;
    }

    .sidebar-title {
        padding: 0.75rem 0.85rem 0.35rem;
        font-size: 0.68rem;
    }

    /* Stats cards more compact */
    .stats-icon {
        width: 45px;
        height: 45px;
        font-size: 1.3rem;
    }

    /* Buttons spacing */
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    /* Table responsive wrapper */
    .table-responsive {
        margin: 0 -1rem;
        padding: 0 1rem;
    }
}

/* Mobile portrait */
@media (max-width: 576px) {
    #main {
        padding: 0.85rem;
    }

    #main header {
        margin-bottom: 0.85rem;
        padding-bottom: 0.65rem;
    }

    .burger-btn {
        width: 38px;
        height: 38px;
        font-size: 1.4rem;
    }

    .page-heading {
        margin-bottom: 0.85rem;
    }

    .page-heading h3 {
        font-size: 1.2rem;
        font-weight: 600;
    }

    .page-content {
        margin-bottom: 2rem;
    }

    .card {
        border-radius: 0.5rem;
        margin-bottom: 0.85rem;
    }

    .card-header {
        padding: 0.75rem 0.85rem;
    }

    .card-header h4 {
        font-size: 0.95rem;
    }

    .card-body {
        padding: 0.85rem;
    }

    /* Even more compact sidebar for very small screens */
    #sidebar {
        width: 260px;
        max-width: 90vw;
    }

    .sidebar-header {
        padding: 1rem 0.85rem 0.85rem;
    }

    .sidebar-header .logo h4 {
        font-size: 1.1rem;
    }

    .sidebar-header .d-flex {
        flex-direction: column;
        gap: 0.75rem;
    }

    .sidebar-header .theme-toggle {
        align-self: flex-start;
        margin-top: 0.5rem;
    }

    .sidebar-item {
        margin: 0.1rem 0.4rem;
    }

    .sidebar-link {
        padding: 0.55rem 0.65rem;
        font-size: 0.875rem;
    }

    .sidebar-link i {
        font-size: 0.95rem;
        margin-right: 0.55rem;
        width: 20px;
    }

    .sidebar-title {
        padding: 0.65rem 0.75rem 0.3rem;
        font-size: 0.65rem;
    }

    /* Hide sidebar toggler X button on very small screens - use overlay instead */
    .sidebar-toggler.x {
        display: none;
    }

    /* Stats cards stack vertically with better spacing */
    .stats-icon {
        width: 42px;
        height: 42px;
        font-size: 1.2rem;
    }

    .font-extrabold {
        font-size: 1.5rem;
    }

    /* Form elements */
    .form-label {
        font-size: 0.9rem;
        margin-bottom: 0.4rem;
    }

    .form-control,
    .form-select {
        font-size: 0.9rem;
        padding: 0.5rem 0.75rem;
    }

    .btn {
        padding: 0.45rem 0.85rem;
        font-size: 0.875rem;
    }

    /* Footer */
    footer {
        padding: 1rem 0;
        margin-top: 2rem;
    }

    footer .footer {
        font-size: 0.8rem;
    }
}

/* Extra small screens (landscape phones) */
@media (max-width: 480px) {
    #main {
        padding: 0.75rem;
    }

    .page-heading h3 {
        font-size: 1.1rem;
    }

    .card-header h4 {
        font-size: 0.9rem;
    }

    .btn-sm {
        padding: 0.35rem 0.65rem;
        font-size: 0.8rem;
    }
}

/* Improve touch targets on mobile */
@media (hover: none) and (pointer: coarse) {
    .sidebar-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .btn {
        min-height: 44px;
    }

    .burger-btn {
        min-width: 44px;
        min-height: 44px;
    }
}

/* Card Header Actions - Better mobile layout for button groups */
.card-header .d-flex {
    gap: 0.75rem;
}

.card-header h4 {
    flex-shrink: 0;
}

/* Mobile improvements for cards with action buttons */
@media (max-width: 992px) {
    .card-header .d-flex {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .card-header h4 {
        width: 100%;
        margin-bottom: 0 !important;
    }

    /* Button container in card header */
    .card-header .d-flex > div {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    /* All buttons in card header full width on mobile */
    .card-header .btn {
        width: 100%;
        justify-content: center;
        margin: 0 !important;
    }

    /* Remove inline margins */
    .card-header .me-2,
    .card-header .ms-2 {
        margin-right: 0 !important;
        margin-left: 0 !important;
    }
}

@media (max-width: 768px) {
    /* Tighter spacing on smaller screens */
    .card-header .d-flex {
        gap: 0.75rem;
    }

    .card-header .d-flex > div {
        gap: 0.5rem;
    }

    /* Slightly smaller buttons for mobile */
    .card-header .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    /* Card body adjustments */
    .card-body .row {
        margin-left: 0;
        margin-right: 0;
    }

    .card-body .row > [class*="col-"] {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
        margin-bottom: 0.75rem;
    }

    /* Search and filter inputs full width stacked */
    .card-body .row.mb-3 .col-md-8,
    .card-body .row.mb-3 .col-md-4 {
        width: 100%;
        margin-bottom: 0.75rem;
    }

    .card-body .row.mb-3 .col-md-4:last-child {
        margin-bottom: 0;
    }
}

@media (max-width: 576px) {
    /* Extra compact for small screens */
    .card-header {
        padding: 0.75rem;
    }

    .card-header h4 {
        font-size: 1rem;
    }

    .card-header .btn {
        padding: 0.45rem 0.85rem;
        font-size: 0.875rem;
    }

    /* Icon spacing in buttons */
    .btn i {
        margin-right: 0.35rem;
    }

    /* Table responsive improvements */
    .table-responsive {
        margin: 0 -0.75rem;
    }

    /* Bulk action alert */
    .alert.d-flex {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem;
    }

    .alert.d-flex .btn {
        width: 100%;
    }

    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .page-link {
        padding: 0.4rem 0.65rem;
        font-size: 0.85rem;
    }
}

/* Dark mode toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
}

/* Dark Mode Styles */
body.theme-dark {
    background-color: #1a1d24;
    color: #dee2e6;
}

/* Sidebar Dark Mode */
body.theme-dark #sidebar {
    background: #25293c;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}

body.theme-dark .sidebar-header {
    border-bottom-color: #3e4259;
}

body.theme-dark .sidebar-title {
    color: #a6abc8;
}

body.theme-dark .sidebar-link {
    color: #dee2e6;
}

body.theme-dark .sidebar-link:hover {
    background-color: #2f3349;
    color: #7c8adb;
}

body.theme-dark .sidebar-item.active .sidebar-link {
    background-color: var(--bs-primary);
    color: #fff;
}

/* Main Content Dark Mode */
body.theme-dark .page-heading h3 {
    color: #dee2e6;
}

/* Cards Dark Mode */
body.theme-dark .card {
    background-color: #25293c;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
}

body.theme-dark .card-header {
    border-bottom-color: #3e4259;
}

body.theme-dark .card-header h4 {
    color: #dee2e6;
}

/* Form Elements Dark Mode */
body.theme-dark .form-control,
body.theme-dark .form-select,
body.theme-dark textarea.form-control {
    background-color: #2f3349;
    border-color: #3e4259;
    color: #e9ecef;
}

body.theme-dark .form-control:focus,
body.theme-dark .form-select:focus,
body.theme-dark textarea.form-control:focus {
    background-color: #2f3349;
    border-color: var(--bs-primary);
    color: #e9ecef;
}

body.theme-dark .form-control::placeholder,
body.theme-dark textarea.form-control::placeholder {
    color: #8892ab;
}

body.theme-dark .form-label {
    color: #e9ecef;
}

body.theme-dark .form-select option {
    background-color: #2f3349;
    color: #e9ecef;
}

body.theme-dark h5 {
    color: #e9ecef;
}

body.theme-dark small,
body.theme-dark .small {
    color: #a6abc8;
}

body.theme-dark .invalid-feedback {
    color: #ff6b6b;
}

body.theme-dark .form-check-label {
    color: #e9ecef;
}

body.theme-dark input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
}

body.theme-dark input[type="number"]::-webkit-inner-spin-button,
body.theme-dark input[type="number"]::-webkit-outer-spin-button {
    opacity: 0.7;
}

/* Table Dark Mode */
body.theme-dark .table {
    color: #e9ecef;
    --bs-table-bg: transparent;
    --bs-table-striped-bg: #2f3349;
    --bs-table-hover-bg: #363b52;
    --bs-table-color: #e9ecef;
}

body.theme-dark .table thead th {
    background-color: #2f3349;
    color: #f8f9fa;
    border-color: #3e4259;
    font-weight: 600;
}

body.theme-dark .table tbody td {
    border-color: #3e4259;
    background-color: transparent;
    color: #e9ecef;
}

body.theme-dark .table tbody tr {
    background-color: transparent;
}

body.theme-dark .table-hover tbody tr:hover {
    background-color: #363b52;
}

body.theme-dark .table tbody td .badge {
    color: #fff;
}

body.theme-dark .table tbody td a {
    color: #7c8adb;
}

body.theme-dark .table tbody td a:hover {
    color: #99a5e0;
}

/* Alerts Dark Mode */
body.theme-dark .alert-success {
    background-color: #1e3a2e;
    border-color: #2d5a45;
    color: #7ed69f;
}

body.theme-dark .alert-danger {
    background-color: #3a1e1e;
    border-color: #5a2d2d;
    color: #f08080;
}

body.theme-dark .alert-warning {
    background-color: #3a3a1e;
    border-color: #5a5a2d;
    color: #ffd966;
}

body.theme-dark .alert-info {
    background-color: #1e2a3a;
    border-color: #2d405a;
    color: #66d9ff;
}

/* Modal Dark Mode */
body.theme-dark .modal-content {
    background-color: #25293c;
    border-color: #3e4259;
}

body.theme-dark .modal-header {
    border-bottom-color: #3e4259;
}

body.theme-dark .modal-footer {
    border-top-color: #3e4259;
}

body.theme-dark .modal-title {
    color: #dee2e6;
}

body.theme-dark .btn-close {
    filter: invert(1);
}

/* Footer Dark Mode */
body.theme-dark footer {
    border-top-color: #3e4259;
}

body.theme-dark footer .footer {
    color: #a6abc8;
}

/* List Group Dark Mode */
body.theme-dark .list-group-item {
    background-color: #25293c;
    color: #dee2e6;
}

body.theme-dark .list-group-item:hover {
    background-color: #2f3349;
}

/* Text Colors Dark Mode */
body.theme-dark .text-muted {
    color: #a6abc8 !important;
}

body.theme-dark .text-dark {
    color: #dee2e6 !important;
}

/* Dropdown Dark Mode */
body.theme-dark .dropdown-menu {
    background-color: #25293c;
    border-color: #3e4259;
}

body.theme-dark .dropdown-item {
    color: #dee2e6;
}

body.theme-dark .dropdown-item:hover {
    background-color: #2f3349;
    color: #fff;
}

/* Pagination Dark Mode */
body.theme-dark .page-link {
    background-color: #25293c;
    border-color: #3e4259;
    color: #dee2e6;
}

body.theme-dark .page-link:hover {
    background-color: #2f3349;
    border-color: #3e4259;
    color: #7c8adb;
}

body.theme-dark .page-item.active .page-link {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
}

body.theme-dark .page-item.disabled .page-link {
    background-color: #2f3349;
    border-color: #3e4259;
    color: #6c757d;
}
