/* =====================================================
   Village Management System - Custom Styles
   ===================================================== */

:root {
    --sidebar-width: 260px;
    --header-height: 60px;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* =====================================================
   Base Styles
   ===================================================== */
body {
    font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f5f7fb;
}

[data-bs-theme="dark"] body {
    background-color: #1a1d21;
}

.wrapper {
    display: flex;
    min-height: 100vh;
}

/* =====================================================
   Sidebar Styles
   ===================================================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--primary-gradient);
    color: white;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease;
}

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

.sidebar-logo {
    max-height: 60px;
    max-width: 100%;
    margin-bottom: 10px;
    border-radius: 8px;
}

.sidebar-logo-placeholder {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px;
    font-size: 1.5rem;
}

.sidebar-title {
    font-size: 1rem;
    margin: 0;
    font-weight: 600;
    line-height: 1.3;
}

.sidebar-nav {
    flex: 1;
    padding: 15px 0;
    overflow-y: auto;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

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

.sidebar-nav .nav-link.active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border-left-color: white;
}

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

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

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

.content-wrapper {
    flex: 1;
    padding: 0;
}

/* =====================================================
   Header Styles
   ===================================================== */
.main-header {
    height: var(--header-height);
    background: var(--bs-body-bg);
    border-bottom: 1px solid var(--bs-border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

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

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

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.sidebar-toggle {
    padding: 5px;
    font-size: 1.5rem;
    color: var(--bs-body-color);
}

.theme-toggle,
.user-menu {
    color: var(--bs-body-color);
    font-size: 1.1rem;
    padding: 5px 10px;
}

.theme-toggle:hover,
.user-menu:hover {
    color: var(--bs-primary);
}

/* =====================================================
   Footer Styles
   ===================================================== */
.main-footer {
    padding: 15px 20px;
    background: var(--bs-body-bg);
    border-top: 1px solid var(--bs-border-color);
}

/* =====================================================
   Card Styles
   ===================================================== */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

[data-bs-theme="dark"] .card {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--bs-border-color);
    padding: 15px 20px;
}

.card-title {
    font-weight: 600;
    margin: 0;
}

.card-body {
    padding: 20px;
}

/* =====================================================
   Stat Cards
   ===================================================== */
.stat-card {
    border-radius: 12px;
    overflow: hidden;
}

.stat-card .card-body {
    padding: 20px;
}

.stat-icon {
    font-size: 2.5rem;
    opacity: 0.3;
}

/* =====================================================
   Form Styles
   ===================================================== */
.form-control,
.form-select {
    border-radius: 8px;
    padding: 10px 15px;
}

.form-control:focus,
.form-select:focus {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.25);
    border-color: #667eea;
}

.form-label {
    font-weight: 500;
    margin-bottom: 6px;
}

/* =====================================================
   Button Styles
   ===================================================== */
.btn {
    border-radius: 8px;
    padding: 8px 16px;
    font-weight: 500;
}

.btn-primary {
    background: var(--primary-gradient);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #5a6fd6 0%, #6a4190 100%);
}

/* =====================================================
   Table Styles
   ===================================================== */
.table {
    margin: 0;
}

.table th {
    font-weight: 600;
    white-space: nowrap;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 6px !important;
}

/* =====================================================
   Badge Styles
   ===================================================== */
.badge {
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 6px;
}

/* =====================================================
   Dark Mode
   ===================================================== */
[data-bs-theme="dark"] .sidebar {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
}

[data-bs-theme="dark"] .theme-icon-dark {
    display: none !important;
}

[data-bs-theme="dark"] .theme-icon-light {
    display: inline-block !important;
}

[data-bs-theme="light"] .theme-icon-dark {
    display: inline-block !important;
}

[data-bs-theme="light"] .theme-icon-light {
    display: none !important;
}

/* =====================================================
   Responsive Styles
   ===================================================== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

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

    .main-content {
        margin-left: 0;
    }
}

@media (max-width: 767.98px) {
    .page-title {
        font-size: 1rem;
    }

    .card-body {
        padding: 15px;
    }

    .stat-card .card-body {
        padding: 15px;
    }

    .stat-icon {
        font-size: 2rem;
    }
}

/* =====================================================
   Utilities
   ===================================================== */
.sticky-top {
    position: sticky;
    top: 80px;
}

/* DataTables Override */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    margin-bottom: 15px;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    margin-top: 15px;
}

/* SweetAlert2 Dark Mode */
[data-bs-theme="dark"] .swal2-popup {
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .swal2-title,
[data-bs-theme="dark"] .swal2-html-container {
    color: var(--bs-body-color);
}

/* Print Styles */
@media print {
    .sidebar,
    .main-header,
    .main-footer,
    .no-print {
        display: none !important;
    }

    .main-content {
        margin: 0 !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}
