/* ============================================================
   GILGAMEZ — ADMIN PANEL MAIN CONTENT (SECTION C)
   Standardized Workspace & 3-Part View Hierarchy (Rule #18)
   5-Tier Responsive Architecture (Rule #6)
   ============================================================ */

/* --- 1. Main Viewport Container ------------------------------- */
#admin-main, .admin-main {
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    background-color: var(--bg-base, #0a0c10);
}

.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.page-content {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px;
    position: relative;
}

/* --- 2. STANDARDIZED ADMIN VIEW TRIAD (Rule #18) -------------- */
/* Root view container inside <div id="app"> */
.admin-page-view, .admin-view-root {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    flex: 1;
    width: 100%;
}

/* Part A: Admin Content Header */
.admin-content-header {
    padding: 20px 28px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, transparent 100%);
    box-sizing: border-box;
}

.admin-content-header-title {
    flex: 1;
    min-width: 260px;
}

.admin-content-header-title h1 {
    font-size: 21px;
    font-weight: 700;
    color: var(--text-primary, #f8fafc);
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.3px;
}

.admin-content-header-title p {
    font-size: 13.5px;
    color: var(--text-secondary, #94a3b8);
    margin: 0;
    line-height: 1.5;
}

.admin-content-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Part B: Admin Content Body */
.admin-content-body {
    flex: 1;
    padding: 22px 28px calc(var(--cc-footer-height, 64px) + 32px);
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-sizing: border-box;
    min-width: 0;
}

.admin-content-body > * {
    width: 100%;
    max-width: none;
    box-sizing: border-box;
}

/* Part C: Admin Content Footer (Mountable Sticky Save & Action Dock) */
.admin-content-footer {
    position: sticky;
    bottom: 0;
    padding: 16px 32px;
    background: var(--theme-bg-surface, var(--bg-surface, rgba(15, 18, 26, 0.94)));
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--theme-border, var(--border, rgba(255, 255, 255, 0.08)));
    border-radius: 0;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    z-index: 40;
    margin-top: auto;
    width: 100%;
    box-sizing: border-box;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.admin-content-footer.is-empty,
.admin-content-footer[data-empty="true"] {
    display: none !important;
}

.admin-footer-status {
    font-size: 13px;
    color: var(--text-secondary, #94a3b8);
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-footer-status:empty {
    display: none;
}

.admin-footer-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.admin-footer-actions:empty {
    display: none;
}

.admin-footer-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 9px 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.admin-footer-actions .btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.admin-footer-actions .btn:active:not(:disabled) {
    transform: translateY(0);
}

.admin-footer-actions .btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* --- 3. Reusable Workspace Cards & Containers ----------------- */
.card {
    background: rgba(22, 24, 34, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    padding: 24px;
    backdrop-filter: blur(8px);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #f8fafc);
    margin: 0;
}

/* Stat Cards */
.stat-card {
    background: rgba(22, 24, 34, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    padding: 24px;
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.stat-card:hover {
    border-color: rgba(99, 102, 241, 0.3);
    transform: translateY(-2px);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.4), transparent);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.stat-card:hover::before {
    opacity: 1;
}

/* --- 4. Buttons ----------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
    font-family: 'Inter', sans-serif;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary, #6366f1), var(--primary-hover, #a855f7));
    color: #fff;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #f8fafc !important;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn-outline {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary, #cbd5e1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary, #f8fafc);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
    background: var(--danger-bg, rgba(239, 68, 68, 0.1));
    color: var(--danger, #ef4444);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* --- 5. Tables ------------------------------------------------ */
.table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

thead {
    background: rgba(255, 255, 255, 0.02);
}

th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    white-space: nowrap;
}

td {
    padding: 14px 16px;
    color: var(--text-secondary, #cbd5e1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tbody tr:hover td {
    background: rgba(255, 255, 255, 0.025);
    color: var(--text-primary, #f8fafc);
}

/* --- 6. Badges & Form Controls -------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-primary {
    background: var(--primary-glow, rgba(99, 102, 241, 0.15));
    color: var(--primary-light, #818cf8);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.badge-muted {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted, #94a3b8);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

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

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary, #cbd5e1);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: var(--text-primary, #f8fafc);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.form-control:focus {
    border-color: var(--primary, #6366f1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

select {
    color-scheme: dark;
}

select option,
select.form-control option {
    background-color: #1e2235 !important;
    color: #f8fafc !important;
    padding: 8px 12px;
}

select option:checked,
select option:hover {
    background-color: #3b82f6 !important;
    color: #ffffff !important;
}

/* Grids */
.content-grid {
    display: grid;
    gap: 24px;
}
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }

/* --- 7. 5-Tier Responsive Main Content Architecture (Rule #6) - */
@media (min-width: 1920px) {
    .page-content {
        max-width: 1800px;
        margin: 0 auto;
        padding: 36px 48px;
    }
}

@media (min-width: 1280px) and (max-width: 1919px) {
    .page-content {
        padding: 28px 32px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .page-content {
        padding: 24px 20px;
    }
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 16px;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .page-content {
        padding: 20px 16px;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px;
    }
    .grid-cols-4,
    .grid-cols-3,
    .grid-cols-2 {
        grid-template-columns: 1fr;
    }
    .admin-content-header {
        padding: 18px 20px 14px;
        gap: 12px;
    }
    .admin-content-body {
        padding: 18px 20px 14px;
        gap: 16px;
    }
    .admin-content-footer {
        padding: 14px 20px;
        border-radius: 0;
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .page-content {
        padding: 14px 10px;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    .stat-card {
        padding: 12px 14px;
        gap: 10px;
    }
    .grid-cols-4,
    .grid-cols-3,
    .grid-cols-2 {
        grid-template-columns: 1fr;
    }
    .btn {
        min-height: 40px;
    }
    .admin-content-header {
        padding: 16px 14px 12px;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .admin-content-header-title {
        min-width: 0;
    }
    .admin-content-header-title h1 {
        font-size: 19px;
    }
    .admin-content-header-actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    .admin-content-header-actions .btn {
        flex: 1 1 auto;
        min-width: 120px;
        justify-content: center;
    }
    .admin-content-body {
        padding: 14px 12px 10px;
        gap: 14px;
    }
    .admin-content-footer {
        padding: 12px 14px;
        border-radius: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .admin-footer-status {
        justify-content: center;
        text-align: center;
        font-size: 12px;
    }
    .admin-footer-actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    .admin-footer-actions .btn {
        flex: 1 1 auto;
        justify-content: center;
    }
}
