:root {
    --bg: #07080d;
    --panel: rgba(12, 16, 28, 0.78);
    --panel-solid: #0c101c;
    --line: rgba(80, 120, 255, 0.25);
    --text: #e8f0ff;
    --muted: #9fb3d9;
    --cyan: #22d3ee;
    --blue: #60a5fa;
    --green: #22c55e;
    --red: #ef4444;
    --orange: #f59e0b;
    --purple: #a78bfa;
    --pink: #ec4899;
    --ig-gradient: linear-gradient(135deg, #f59e0b 0%, #ec4899 50%, #8b5cf6 100%);
}

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

body {
    font-family: "JetBrains Mono", "Space Grotesk", monospace;
    background:
        radial-gradient(600px 400px at 80% -10%, rgba(236, 72, 153, 0.12), transparent 60%),
        radial-gradient(900px 600px at 0% 20%, rgba(96, 165, 250, 0.1), transparent 60%),
        radial-gradient(500px 500px at 50% 80%, rgba(139, 92, 246, 0.06), transparent 60%),
        var(--bg);
    min-height: 100vh;
    color: var(--text);
}

/* ─── Topbar ─── */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    background: rgba(12, 16, 28, 0.85);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-logo { display: flex; align-items: center; gap: 10px; }
.topbar-logo h2 {
    font-size: 1.1rem;
    letter-spacing: 2px;
    background: var(--ig-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.topbar-status {
    font-size: 0.68rem;
    color: var(--green);
    letter-spacing: 0.5px;
}
.topbar-right { display: flex; gap: 8px; }
.topbar-right a, .topbar-right button {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.75rem;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: none;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}
.topbar-right a:hover, .topbar-right button:hover {
    color: var(--text);
    border-color: var(--line);
    background: rgba(34, 211, 238, 0.05);
}

/* ─── Wrap ─── */
.wrap {
    max-width: 1240px;
    margin: 0 auto;
    padding: 24px;
}

/* ─── KPI Grid ─── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.kpi-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px 22px;
    backdrop-filter: blur(8px);
    position: relative;
    overflow: hidden;
    transition: border-color 0.3s, transform 0.2s;
}
.kpi-card:hover {
    border-color: rgba(139, 92, 246, 0.4);
    transform: translateY(-2px);
}
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--ig-gradient);
    border-radius: 14px 14px 0 0;
}
.kpi-card .kpi-label {
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.kpi-card .kpi-value {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text), var(--cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.kpi-card .kpi-sub {
    font-size: 0.7rem;
    color: var(--muted);
    margin-top: 6px;
    line-height: 1.5;
}

/* ─── Tab Navigation ─── */
.tab-nav {
    display: flex;
    gap: 2px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 0;
    overflow-x: auto;
}
.tab-btn {
    padding: 10px 18px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
    font-family: inherit;
}
.tab-btn svg { opacity: 0.5; transition: opacity 0.2s; }
.tab-btn:hover { color: var(--text); }
.tab-btn:hover svg { opacity: 0.8; }
.tab-btn.active {
    color: var(--cyan);
    border-bottom-color: var(--cyan);
}
.tab-btn.active svg { opacity: 1; stroke: var(--cyan); }
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ─── Tables ─── */
.table-wrap {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
}
table {
    width: 100%;
    border-collapse: collapse;
}
thead th {
    padding: 12px 16px;
    font-size: 0.68rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    background: rgba(7, 8, 13, 0.4);
}
tbody td {
    padding: 10px 16px;
    font-size: 0.82rem;
    border-bottom: 1px solid rgba(80, 120, 255, 0.06);
    vertical-align: middle;
}
tbody tr { transition: background 0.15s; }
tbody tr:hover { background: rgba(139, 92, 246, 0.04); }
tbody tr:last-child td { border-bottom: none; }

/* ─── Status Badges ─── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}
.badge-pending { background: rgba(159, 179, 217, 0.12); color: var(--muted); }
.badge-pending::before { background: var(--muted); }
.badge-generating { background: rgba(34, 211, 238, 0.12); color: var(--cyan); }
.badge-generating::before { background: var(--cyan); animation: pulse 1s infinite; }
.badge-ready { background: rgba(96, 165, 250, 0.12); color: var(--blue); }
.badge-ready::before { background: var(--blue); }
.badge-publishing { background: rgba(245, 158, 11, 0.12); color: var(--orange); }
.badge-publishing::before { background: var(--orange); animation: pulse 1s infinite; }
.badge-posted { background: rgba(34, 197, 94, 0.12); color: var(--green); }
.badge-posted::before { background: var(--green); }
.badge-failed { background: rgba(239, 68, 68, 0.12); color: var(--red); }
.badge-failed::before { background: var(--red); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ─── Buttons ─── */
.btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel-solid);
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}
.btn:hover { filter: brightness(1.2); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { border-color: var(--cyan); color: var(--cyan); }
.btn-danger { border-color: var(--red); color: var(--red); }
.btn-success { border-color: var(--green); color: var(--green); }
.btn-sm { padding: 5px 10px; font-size: 0.7rem; }
.btn-glow {
    box-shadow: 0 0 16px rgba(34, 211, 238, 0.15);
}
.btn-glow:hover {
    box-shadow: 0 0 24px rgba(34, 211, 238, 0.3);
}
.btn-glow-green {
    box-shadow: 0 0 16px rgba(34, 197, 94, 0.15);
}
.btn-glow-green:hover {
    box-shadow: 0 0 24px rgba(34, 197, 94, 0.3);
}

/* ─── Forms ─── */
.form-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    align-items: flex-end;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}
.form-group label {
    font-size: 0.68rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px 12px;
    background: rgba(7, 8, 13, 0.6);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.85rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--cyan);
    box-shadow: 0 0 12px rgba(34, 211, 238, 0.1);
}
.form-group textarea { resize: vertical; min-height: 80px; }
select option { background: var(--panel-solid); color: var(--text); }

/* ─── Section Headers ─── */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.section-header h3 {
    font-size: 0.95rem;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ─── Image Thumbnail ─── */
.thumb {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--line);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.thumb-placeholder {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: rgba(159, 179, 217, 0.08);
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--muted);
}

/* ─── Caption Preview ─── */
.caption-preview {
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── Manual Post / Generate Section ─── */
.generate-section {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 24px;
    position: relative;
    overflow: hidden;
}
.generate-section::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--ig-gradient);
}
.generate-section h3 {
    display: flex;
    align-items: center;
    gap: 8px;
}
.preview-card {
    background: rgba(7, 8, 13, 0.5);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 20px;
    margin-top: 16px;
    display: none;
}
.preview-card.show { display: block; animation: fadeIn 0.3s ease; }
.preview-image {
    max-width: 400px;
    max-height: 400px;
    border-radius: 10px;
    border: 1px solid var(--line);
    margin-bottom: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.preview-caption {
    white-space: pre-wrap;
    font-size: 0.85rem;
    line-height: 1.6;
    margin-bottom: 16px;
    padding: 12px;
    background: rgba(7, 8, 13, 0.4);
    border-radius: 8px;
    border: 1px solid rgba(80, 120, 255, 0.1);
}
.preview-actions {
    display: flex;
    gap: 12px;
}

/* ─── Modals ─── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
    background: var(--panel-solid);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 28px;
    width: 550px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal h3 {
    margin-bottom: 20px;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    justify-content: flex-end;
}

/* ─── Image Modal ─── */
.image-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 300;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.image-modal-overlay.show { display: flex; }
.image-modal-overlay img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 10px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}

/* ─── Toasts ─── */
.toast-container {
    position: fixed;
    top: 60px;
    right: 24px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 600;
    animation: slideIn 0.3s ease;
    border: 1px solid;
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    gap: 8px;
}
.toast-success { background: rgba(34, 197, 94, 0.12); border-color: rgba(34, 197, 94, 0.4); color: var(--green); }
.toast-error { background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.4); color: var(--red); }
.toast-info { background: rgba(34, 211, 238, 0.12); border-color: rgba(34, 211, 238, 0.4); color: var(--cyan); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── Days Checkboxes ─── */
.days-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.day-check {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--muted);
}
.day-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--cyan);
}

/* ─── Loading Spinner ─── */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--line);
    border-top-color: var(--cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-msg {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--cyan);
    font-size: 0.85rem;
    padding: 12px 0;
}

/* ─── Toggles ─── */
.toggle-active {
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    transition: all 0.2s;
}
.toggle-active.on { color: var(--green); background: rgba(34, 197, 94, 0.1); }
.toggle-active.off { color: var(--muted); background: rgba(159, 179, 217, 0.08); }
.toggle-active:hover { filter: brightness(1.3); }

/* ─── IG Link ─── */
a.ig-link {
    color: var(--purple);
    text-decoration: none;
    transition: color 0.2s;
}
a.ig-link:hover {
    color: var(--pink);
    text-decoration: underline;
}

/* ─── Account Badge ─── */
.acc-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.68rem;
    font-weight: 600;
    background: rgba(167, 139, 250, 0.1);
    color: var(--purple);
    border: 1px solid rgba(167, 139, 250, 0.2);
}
.acc-badge a.ig-link { color: var(--purple); }
.acc-badge a.ig-link:hover { color: var(--pink); }

/* ─── Preview Account Label ─── */
.preview-account {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--purple);
    margin-bottom: 12px;
}

/* ─── Language Badge ─── */
.lang-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    vertical-align: middle;
    margin-left: 4px;
}
.lang-badge.lang-tr { background: rgba(239, 68, 68, 0.12); color: var(--red); border: 1px solid rgba(239, 68, 68, 0.25); }
.lang-badge.lang-en { background: rgba(96, 165, 250, 0.12); color: var(--blue); border: 1px solid rgba(96, 165, 250, 0.25); }

/* ─── Optgroup ─── */
select optgroup { color: var(--cyan); font-weight: 600; font-size: 0.8rem; }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(80, 120, 255, 0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(80, 120, 255, 0.4); }

/* ─── Responsive ─── */
@media (max-width: 900px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { flex-direction: column; }
    .tab-btn { padding: 8px 12px; font-size: 0.72rem; }
}
@media (max-width: 600px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .wrap { padding: 12px; }
    .topbar { padding: 8px 12px; }
    .tab-btn span { display: none; }
}
