/**
 * Admin Panel Styles
 */

:root {
    --sidebar-width: 260px;
    --header-height: 60px;
    --primary-color: #0d6efd;
    --sidebar-bg: #ffffff;
    --sidebar-text: #495057;
    --sidebar-hover: #f1f3f5;
    --sidebar-active: #1abc9c;
}

/* Reset */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f8f9fa;
    min-height: 100vh;
}

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

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary-color), #0dcaf0);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 1.2rem;
}

.sidebar-brand {
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    margin: 0;
}

.sidebar-nav {
    padding: 0.5rem 0;
}

.nav-header {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 1rem 1.25rem 0.5rem;
    color: #6c757d;
    font-weight: 600;
}

.nav-item {
    margin: 2px 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.nav-link:hover {
    background-color: var(--sidebar-hover);
    color: white;
}

.nav-link.active {
    background-color: var(--sidebar-active);
    color: white;
}

.nav-link i {
    font-size: 1.1rem;
    width: 1.5rem;
    text-align: center;
}

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

/* Header */
.admin-header {
    position: sticky;
    top: 0;
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-toggle {
    display: none;
    padding: 0.5rem;
    border: none;
    background: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: #6c757d;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-dropdown {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background-color: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

.user-info {
    text-align: right;
}

.user-name {
    font-weight: 500;
    font-size: 0.9rem;
    color: #212529;
}

.user-role {
    font-size: 0.75rem;
    color: #6c757d;
}

/* Page Content */
.page-content {
    flex: 1;
    padding: 1.5rem;
}

/* Page Header */
.page-header {
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #212529;
    margin: 0 0 0.25rem;
}

.page-subtitle {
    color: #6c757d;
    font-size: 0.9rem;
}

/* Breadcrumb */
.breadcrumb {
    font-size: 0.875rem;
    background: none;
    padding: 0;
    margin-bottom: 0.5rem;
}

/* Card */
.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    border-radius: 0.5rem;
}

.card-header {
    background-color: white;
    border-bottom: 1px solid #e9ecef;
    padding: 1rem 1.25rem;
}

.card-body {
    padding: 1.25rem;
}

/* Table */
.table {
    margin-bottom: 0;
}

.table th {
    font-weight: 600;
    color: #495057;
    border-top: none;
    white-space: nowrap;
}

.table th.sortable {
    cursor: pointer;
    user-select: none;
}

.table th.sortable:hover {
    background-color: #f8f9fa;
}

.table th .sort-icon {
    opacity: 0.3;
    font-size: 0.75rem;
}

.table th.sorted-asc .sort-icon::before {
    content: "\F128";
    opacity: 1;
}

.table th.sorted-desc .sort-icon::before {
    content: "\F127";
    opacity: 1;
}

.table td {
    vertical-align: middle;
}

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

/* Actions */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.toolbar-right {
    margin-left: auto;
}

.search-box {
    position: relative;
    width: 280px;
}

.search-box .form-control {
    padding-left: 2.25rem;
}

.search-box .search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
}

/* Button Group */
.btn-group-sm>.btn {
    padding: 0.35rem 0.5rem;
}

/* Badges */
.badge {
    font-weight: 500;
    padding: 0.35em 0.65em;
}

/* Pagination */
.pagination {
    margin-bottom: 0;
}

.page-link {
    color: #495057;
    border-color: #dee2e6;
}

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

/* Loading Overlay */
#loadingOverlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    text-align: center;
}

.loading-spinner .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Form */
.form-label {
    font-weight: 500;
    color: #495057;
    margin-bottom: 0.375rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)), url("https://images.unsplash.com/photo-1486406146926-c627a92ad1ab?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=2070&q=80");
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: white;
    border-radius: 1rem;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.175);
    padding: 2.5rem;
}

.login-logo {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary-color), #0dcaf0);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.75rem;
    margin: 0 auto 1.5rem;
}

.login-title {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.login-subtitle {
    text-align: center;
    color: #6c757d;
    margin-bottom: 2rem;
}

/* Detail View */
.detail-row {
    padding: 0.75rem 0;
    border-bottom: 1px solid #e9ecef;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    font-weight: 500;
    color: #6c757d;
    font-size: 0.875rem;
}

.detail-value {
    color: #212529;
}

/* Stats Cards */
.stat-card {
    border-radius: 0.75rem;
    padding: 1.25rem;
    color: white;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

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

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
}

.stat-card .stat-label {
    opacity: 0.8;
    font-size: 0.875rem;
}

.stat-card.bg-primary {
    background: linear-gradient(135deg, #0d6efd, #0dcaf0);
}

.stat-card.bg-success {
    background: linear-gradient(135deg, #198754, #20c997);
}

.stat-card.bg-warning {
    background: linear-gradient(135deg, #fd7e14, #ffc107);
}

.stat-card.bg-danger {
    background: linear-gradient(135deg, #dc3545, #fd7e14);
}

/* Toast */
.toast-container {
    z-index: 9999;
}

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

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

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

    .sidebar-toggle {
        display: block;
    }

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

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

@media (max-width: 575.98px) {
    .page-content {
        padding: 1rem;
    }

    .toolbar {
        flex-direction: column;
    }

    .toolbar-right {
        margin-left: 0;
        width: 100%;
    }

    .search-box {
        width: 100%;
    }

    .card-body {
        padding: 1rem;
    }
}

/* Utilities */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cursor-pointer {
    cursor: pointer;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}