/* =========================================
   Admin Dashboard Styles
   ========================================= */

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

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

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.login-overlay.hidden {
    display: none;
}

.login-card {
    background: white;
    width: 380px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    padding: 32px;
    text-align: center;
    color: white;
}

.login-header h2 {
    font-size: 24px;
    margin-bottom: 8px;
}

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

.login-body {
    padding: 32px;
}

.login-body .form-group {
    margin-bottom: 20px;
}

.login-body .form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
}

.login-body .form-group input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
}

.login-body .form-group input:focus {
    outline: none;
    border-color: #1a1a2e;
    box-shadow: 0 0 0 3px rgba(26, 26, 46, 0.1);
}

.login-error {
    background: #fff2f0;
    border: 1px solid #ffccc7;
    color: #ff4d4f;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
    text-align: center;
}

.login-error.hidden {
    display: none;
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: #1a1a2e;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-login:hover {
    background: #2a2a4e;
}

.btn-login:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Admin App Container */
.admin-app {
    display: flex;
    width: 100%;
}

.admin-app.hidden {
    display: none;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: #1a1a2e;
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
}

.logo {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo h2 {
    font-size: 18px;
    font-weight: 600;
}

.logo .tag {
    background: #ff2442;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
}

.nav-menu {
    flex: 1;
    padding: 20px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-left: 3px solid #ff2442;
}

.nav-item .icon {
    font-size: 18px;
}

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

.btn-logout {
    width: 100%;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 24px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.header h1 {
    font-size: 24px;
    color: #1a1a2e;
}

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

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

.avatar {
    width: 40px;
    height: 40px;
    background: #eee;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

/* Sections */
.section {
    display: none;
}

.section.active {
    display: block;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 56px;
    height: 56px;
    background: #f5f7fa;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-info h3 {
    font-size: 28px;
    color: #1a1a2e;
    margin-bottom: 4px;
}

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

/* Chart */
.chart-container {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.chart-container h3 {
    margin-bottom: 20px;
    color: #1a1a2e;
}

.chart-placeholder {
    height: 300px;
    background: #f9fafb;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
}

/* Toolbar */
.toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.search-input,
.filter-select,
.date-input {
    padding: 10px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}

.search-input {
    flex: 1;
    max-width: 300px;
}

.search-input:focus,
.filter-select:focus {
    border-color: #ff2442;
}

.btn-refresh {
    padding: 10px 20px;
    background: #1a1a2e;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-refresh:hover {
    background: #2a2a4e;
}

/* Data Table */
.data-table {
    width: 100%;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
}

.data-table th {
    background: #f9fafb;
    font-weight: 600;
    color: #666;
    font-size: 13px;
    text-transform: uppercase;
}

.data-table td {
    color: #333;
    font-size: 14px;
}

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

.empty-state {
    text-align: center;
    color: #999;
    padding: 40px !important;
}

/* Action Buttons */
.btn-action {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    margin-right: 6px;
}

.btn-edit {
    background: #e3f2fd;
    color: #1976d2;
}

.btn-delete {
    background: #ffebee;
    color: #d32f2f;
}

.btn-top {
    background: #e1f5fe;
    color: #0288d1;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 20px;
}

.btn-page {
    padding: 8px 16px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
}

.btn-page:hover {
    background: #f5f5f5;
}

#page-info {
    color: #666;
    font-size: 14px;
}

/* Settings */
.settings-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

.settings-card h3 {
    margin-bottom: 20px;
    color: #1a1a2e;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #666;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    max-width: 400px;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
}

.form-group input:focus {
    outline: none;
    border-color: #ff2442;
}

.btn-save {
    padding: 12px 24px;
    background: #ff2442;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
}

.btn-save:hover {
    opacity: 0.9;
}

/* Membership Badge */
.badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-free {
    background: #f5f5f5;
    color: #666;
}

.badge-pro {
    background: #e3f2fd;
    color: #1976d2;
}

.badge-vip {
    background: #fff8e1;
    color: #f57c00;
}

/* Responsive */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }

    .sidebar .logo h2,
    .sidebar .logo .tag,
    .nav-item span:last-child,
    .sidebar-footer {
        display: none;
    }

    .main-content {
        margin-left: 60px;
    }

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

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.hidden {
    display: none;
}

.modal-card {
    background: white;
    width: 500px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    color: #1a1a2e;
}

.btn-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    background: #f9fafb;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-cancel {
    padding: 10px 20px;
    background: white;
    border: 1px solid #dcdfe6;
    border-radius: 6px;
    cursor: pointer;
}

.btn-save-confirm {
    padding: 10px 24px;
    background: #1a1a2e;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

/* Status Toggle */
.status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-active {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-disabled {
    background: #fafafa;
    color: #9e9e9e;
}

.btn-primary {
    padding: 10px 20px;
    background: #ff2442;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
}

.btn-primary:hover {
    opacity: 0.9;
}

/* Image Preview Modal Specific */
.image-preview-card {
    width: 80% !important;
    max-width: 900px !important;
}

.preview-body {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #1a1a2e;
    padding: 20px;
    min-height: 400px;
}

#preview-img {
    max-width: 100%;
    max-height: 75vh;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.preview-loading {
    color: #fff;
    font-size: 16px;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    border-radius: 4px;
    margin-top: 20px;
}


/* Timeout & Warning UI */
.timeout-fix-notice {
    text-align: left;
    background: #fff2f0;
    border: 1px solid #ffccc7;
    padding: 20px;
    border-radius: 8px;
    color: #434343;
    max-width: 600px;
    margin: 20px auto;
}

.timeout-fix-notice code {
    display: block;
    background: #1a1a2e;
    color: #00ff00;
    padding: 12px;
    border-radius: 6px;
    margin-top: 10px;
    font-family: monospace;
    user-select: all;
    cursor: pointer;
}

.query-warning {
    background: #fffbe6;
    border: 1px solid #ffe58f;
    color: #856404;
    padding: 10px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 13px;
    display: flex;
    align-items: center;
}
/* Switch Toggle */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.switch input { opacity: 0; width: 0; height: 0; position: absolute;}
.switch input + span::before {
  content: '';
  display: inline-block;
  width: 36px;
  height: 20px;
  background-color: #ccc;
  border-radius: 20px;
  vertical-align: middle;
  transition: .4s;
  margin-right: 8px;
  position: relative;
}
.switch input + span::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  height: 16px;
  width: 16px;
  left: 2px;
  background-color: white;
  border-radius: 50%;
  transition: .4s;
  pointer-events: none;
}
/* Checked State */
.switch input:checked + span::before {
  background-color: #2e7d32;
}
.switch input:checked + span::after {
  transform: translate(16px, -50%);
}
