/* Admin Dashboard Theme - Modern Clean Design */
/* Inspired by Bootstrap 4 Admin Templates */

:root {
    --primary-color: #4e73df;
    --primary-dark: #2e59d9;
    --primary-light: #6f8fe9;
    --secondary-color: #858796;
    --success-color: #1cc88a;
    --info-color: #36b9cc;
    --warning-color: #f6c23e;
    --danger-color: #e74a3b;
    --light-color: #f8f9fc;
    --dark-color: #5a5c69;
    --sidebar-width: 260px;
    --topbar-height: 65px;
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background: var(--light-color);
    color: var(--dark-color);
    font-size: 14px;
    line-height: 1.5;
}

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

/* Sidebar */
.admin-sidebar {
    width: var(--sidebar-width);
    background-image: linear-gradient(180deg, rgba(78, 115, 223, 0.85) 0%, rgba(34, 74, 190, 0.85) 100%), url('../../bpic.jpg');
    background-size: auto, cover;
    background-position: center, center;
    background-repeat: no-repeat, no-repeat;
    color: white;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    height: 100vh;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
    transition: transform 0.3s ease;
}

.admin-sidebar.collapsed {
    transform: translateX(-100%) !important;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--topbar-height);
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    font-size: 1.2rem;
    font-weight: 700;
    text-decoration: none;
    color: white;
}

.sidebar-brand:hover {
    color: white;
}

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

.nav-section-title {
    padding: 1rem 1.5rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.5px;
}

.nav-item {
    list-style: none;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

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

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

.nav-link i {
    width: 20px;
    margin-right: 0.75rem;
    font-size: 1rem;
}

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

.admin-main.expanded {
    margin-left: 0;
    width: 100%;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    background: none;
    border: none;
    color: var(--dark-color);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    margin-right: 1rem;
    transition: all 0.2s;
    border-radius: 0.25rem;
    z-index: 100;
    position: relative;
}

.sidebar-toggle:hover {
    background: var(--light-color);
    color: var(--primary-color);
}

/* Topbar */
.admin-topbar {
    height: var(--topbar-height);
    background: white;
    border-bottom: 1px solid #e3e6f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.05);
}

.topbar-search {
    flex: 0 0 400px;
}

.topbar-search input {
    width: 100%;
    padding: 0.5rem 1rem;
    border: 1px solid #d1d3e2;
    border-radius: 2rem;
    font-size: 0.875rem;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    list-style: none;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 0.35rem;
    color: var(--dark-color);
    text-decoration: none;
    transition: background 0.2s;
}

.topbar-user:hover {
    background: var(--light-color);
}

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

/* Content Area */
.admin-content {
    padding: 1.5rem;
    flex: 1;
}

/* Page Header */
.page-header {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 400;
    color: var(--dark-color);
    margin: 0;
}

.page-breadcrumb {
    display: flex;
    gap: 0.5rem;
    list-style: none;
    font-size: 0.875rem;
    color: var(--secondary-color);
}

/* Cards */
.card {
    background: white;
    border: 1px solid #e3e6f0;
    border-radius: 0.35rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.05);
}

.card-header {
    padding: 0.75rem 1.25rem;
    background: #f8f9fc;
    border-bottom: 1px solid #e3e6f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
}

.card-body {
    padding: 1.25rem;
}

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

.stat-card {
    background: white;
    border-left: 4px solid;
    border-radius: 0.35rem;
    padding: 1.25rem;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.stat-info {
    flex: 1;
}

.stat-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--primary-color);
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark-color);
    margin-top: 0.25rem;
}

.stat-icon {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--light-color);
    color: var(--secondary-color);
    font-size: 1.5rem;
}

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

.data-table thead {
    background: var(--light-color);
}

.data-table th {
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--dark-color);
    border-bottom: 2px solid #e3e6f0;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.data-table td {
    padding: 0.75rem;
    border-bottom: 1px solid #e3e6f0;
    font-size: 0.875rem;
}

.data-table tbody tr:hover {
    background: #f8f9fc;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.35rem;
    font-size: 0.875rem;
    font-weight: 400;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

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

.btn-success:hover {
    background: #17a673;
}

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

.btn-danger:hover {
    background: #c9302c;
}

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

.btn-warning:hover {
    background: #f4b30d;
}

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

.btn-info:hover {
    background: #2c9faf;
}

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

.btn-secondary:hover {
    background: #6b6d7d;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

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

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

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

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--dark-color);
}

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d3e2;
    border-radius: 0.35rem;
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.25);
}

.form-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d3e2;
    border-radius: 0.35rem;
    font-size: 0.875rem;
    background: white;
}

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: 0.35rem;
    margin-bottom: 1rem;
    border-left: 4px solid;
}

.alert-success {
    background: #d1f2eb;
    border-left-color: var(--success-color);
    color: #0f6848;
}

.alert-danger {
    background: #f8d7da;
    border-left-color: var(--danger-color);
    color: #842029;
}

.alert-warning {
    background: #fff3cd;
    border-left-color: var(--warning-color);
    color: #997404;
}

.alert-info {
    background: #d1ecf1;
    border-left-color: var(--info-color);
    color: #055160;
}

/* Pagination */
.pagination {
    display: flex;
    gap: 0.25rem;
    list-style: none;
    margin-top: 1rem;
}

.page-item {
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d3e2;
    border-radius: 0.35rem;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.page-item:hover {
    background: var(--light-color);
    border-color: var(--primary-color);
}

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

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--primary-color); }
.text-success { color: var(--success-color); }
.text-danger { color: var(--danger-color); }
.text-warning { color: var(--warning-color); }
.text-muted { color: var(--secondary-color); }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }


/* Scrollbar */
.admin-sidebar::-webkit-scrollbar {
    width: 6px;
}

.admin-sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

.admin-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.admin-sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Link Box และปุ่มคัดลอก */
.link-group {
    margin-bottom: 1rem;
}

.link-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--dark-color);
}

.link-box {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.link-box input[type="text"] {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d3e2;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    background: var(--light-color);
}

.link-box button {
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.link-box button:hover {
    background: var(--primary-dark);
}

.link-box button.copied {
    background: var(--success-color);
}

/* Upload Progress */
.upload-progress {
    margin: 1.5rem 0;
}

.progress-bar {
    width: 100%;
    height: 30px;
    background: #e9ecef;
    border-radius: 0.5rem;
    overflow: hidden;
    position: relative;
    border: 2px solid #d1d3e2;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4e73df 0%, #6f8fe9 100%);
    transition: width 0.1s linear;
    width: 0%;
    position: relative;
    overflow: hidden;
    min-width: 0;
    box-shadow: 0 2px 4px rgba(78, 115, 223, 0.3);
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.progress-text {
    text-align: center;
    margin-top: 0.5rem;
    font-weight: 600;
    color: var(--primary-color);
    font-size: 1rem;
}

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

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

/* Mobile Close Button */
.sidebar-mobile-close {
    display: none;
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: background 0.2s;
    line-height: 1;
    pointer-events: auto;
}

.sidebar-mobile-close:active {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0.95);
}

.sidebar-mobile-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
    /* Hide sidebar by default on mobile */
    .admin-sidebar {
        transform: translateX(-100%);
        height: 100% !important;
        min-height: 100vh !important;
        min-height: 100dvh !important;
    }

    /* Show sidebar when toggled */
    .admin-sidebar.mobile-open {
        transform: translateX(0) !important;
        height: 100% !important;
        min-height: 100vh !important;
        min-height: 100dvh !important;
    }

    /* Show mobile close button */
    .sidebar-mobile-close {
        display: flex !important;
    }

    /* Main content takes full width on mobile */
    .admin-main {
        margin-left: 0;
        width: 100%;
    }

    /* Topbar adjustments */
    .admin-topbar {
        padding: 0 1rem;
    }

    .topbar-title {
        font-size: 1rem;
    }

    /* Content padding */
    .admin-content {
        padding: 1rem;
    }

    /* Cards */
    .stats-grid {
        grid-template-columns: 1fr;
    }

    /* Tables - make scrollable */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Buttons - stack on mobile */
    .btn-group {
        flex-direction: column;
        width: 100%;
    }

    .btn-group .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    /* Modals - full width on mobile */
    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }

    /* Form groups - full width */
    .form-row {
        flex-direction: column;
    }

    .form-group {
        width: 100% !important;
    }
}

/* Tablet adjustments */
@media (max-width: 992px) and (min-width: 769px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
