/* ============================================================
   HESABU ELITES CMS STUDIO — MODERN DARK THEME CSS
   ============================================================ */

:root {
    --bg-base: #060e17;
    --bg-surface: #0a1926;
    --bg-card: #0f2233;
    --bg-hover: #162f46;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-focus: #008744;
    
    --primary: #008744;
    --primary-hover: #00aa55;
    --gold: #e0a328;
    --gold-hover: #f0b439;
    --teal: #0fa3b1;
    --danger: #ef4444;
    --danger-hover: #dc2626;

    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --text-dim: #64748b;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Auth / Login Page */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 50% 20%, #0d2b45 0%, #060e17 80%);
    padding: 20px;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 440px;
    padding: 40px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.auth-header {
    text-align: center;
    margin-bottom: 28px;
}

.auth-logo {
    width: 58px;
    height: 58px;
    border-radius: 12px;
    margin-bottom: 16px;
}

.auth-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.auth-header p {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 4px;
}

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    letter-spacing: 0.2px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 11px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    background: rgba(255, 255, 255, 0.07);
    box-shadow: 0 0 0 3px rgba(0, 135, 68, 0.2);
}

.alert-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--danger);
    color: #fca5a5;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 12px;
    color: var(--text-dim);
}

/* Dashboard Shell */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.brand-logo {
    width: 36px;
    height: 36px;
    border-radius: 8px;
}

.brand-title {
    font-weight: 800;
    font-size: 16px;
    letter-spacing: 0.5px;
    color: #fff;
    display: block;
}

.brand-subtitle {
    font-size: 11px;
    font-weight: 600;
    color: var(--gold);
    letter-spacing: 1.5px;
    display: block;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: all 0.2s ease;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    flex-shrink: 0;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.nav-item.active {
    background: rgba(0, 135, 68, 0.15);
    color: #34d399;
    font-weight: 600;
}

.badge-pill {
    margin-left: auto;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 12px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.15);
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.user-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
}

.user-email {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Topbar */
.main-viewport {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow-x: hidden;
}

.topbar {
    height: 72px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-left h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.topbar-status {
    font-size: 12px;
    color: var(--text-dim);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 14px rgba(0, 135, 68, 0.35);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border-color: var(--border-color);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
}

.btn-outline-danger {
    background: transparent;
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}
.btn-outline-danger:hover {
    background: rgba(239, 68, 68, 0.15);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
}

/* Tabs & Content */
.tab-pane {
    display: none;
    padding: 32px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.tab-pane.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Cards & Layout */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.card-welcome {
    background: linear-gradient(135deg, rgba(13, 43, 69, 0.5) 0%, rgba(0, 135, 68, 0.15) 100%);
    border-color: rgba(0, 135, 68, 0.3);
}

.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
}

.full-width {
    grid-column: 1 / -1;
}

.text-muted { color: var(--text-muted); font-size: 14px; }
.text-gold { color: var(--gold); }
.text-teal { color: var(--teal); }

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-num {
    font-size: 32px;
    font-weight: 800;
    margin: 8px 0 4px;
    letter-spacing: -0.5px;
}

.stat-hint {
    font-size: 12px;
    color: var(--text-dim);
}

/* Status Toggle Box */
.status-toggle-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.03);
    padding: 16px 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.toggle-switch-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #334155;
    transition: .3s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

.status-indicator {
    font-weight: 700;
    font-size: 13px;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(224, 163, 40, 0.15);
    color: var(--gold);
}

.status-indicator.live {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

/* Products Grid in Admin */
.products-grid-admin {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 18px;
}

.product-admin-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.product-admin-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.product-admin-header h4 {
    font-size: 16px;
    font-weight: 700;
}

.product-admin-desc {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 14px;
    flex: 1;
}

.product-admin-meta {
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

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

th {
    text-align: left;
    padding: 12px 14px;
    color: var(--text-dim);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 14px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Modals */
.cms-modal-backdrop {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.cms-modal-backdrop.active {
    display: flex;
}

.cms-modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 60px rgba(0,0,0,0.7);
    overflow: hidden;
}

.cms-modal-header {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.cms-modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.cms-modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}

.cms-modal-body {
    padding: 24px;
    overflow-y: auto;
}

.cms-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    background: rgba(0,0,0,0.15);
}

.file-uploader-row {
    display: flex;
    gap: 8px;
}

.file-uploader-row input[type="text"] {
    flex: 1;
}

/* Media Grid */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.media-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    text-align: center;
    transition: all 0.2s ease;
}

.media-card:hover {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.06);
}

.media-preview {
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.2);
    margin-bottom: 8px;
    overflow: hidden;
}

.media-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.media-name {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 6px;
}

/* Floating Toast */
.toast-popup {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #10b981;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 999;
}

.toast-popup.active {
    transform: translateY(0);
    opacity: 1;
}

/* Image Editor Grid */
.image-editor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.image-edit-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.image-edit-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    display: block;
}

.image-preview-box {
    height: 160px;
    background: #04090f;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.image-preview-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.image-edit-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.image-edit-controls input[type="text"] {
    flex: 1;
    font-size: 12px;
    padding: 8px 10px;
}

@media (max-width: 900px) {
    .app-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
    .form-grid-2 {
        grid-template-columns: 1fr;
    }
}
