@import url('https://fonts.googleapis.com/css2?family=Syne:wght@600;700;800&family=DM+Sans:wght@300;400;500;600&family=Roboto+Condensed:wght@700&family=Oswald:wght@600;700&family=Lato:wght@700;900&family=Montserrat:wght@700;800;900&family=Poppins:wght@700;800&family=Teko:wght@600;700&display=swap&subset=latin-ext');

:root {
    --bg: #060a1e;
    --surface: #0d1535;
    --surface2: #142044;
    --border: #1a3a6e;
    --border-hover: #2a5a9e;
    --text: #e8edf5;
    --text-muted: #7a9abf;
    --text-dim: #3a5a8a;
    --accent: #3a7aee;
    --accent2: #7aabff;
    --green: #22c55e;
    --red: #ef4444;
    --canva: #a78bfa;
}

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

html, body { height: 100%; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

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

.sidebar {
    width: 220px; background: var(--surface); border-right: 1px solid var(--border);
    padding: 20px 16px; display: flex; flex-direction: column; gap: 8px; flex-shrink: 0;
}
.sidebar-logo {
    font-family: 'Syne', sans-serif; font-weight: 800; font-size: 18px;
    letter-spacing: -0.5px; margin-bottom: 8px; padding: 0 8px;
}
.sidebar-logo span { color: var(--accent); }
.sidebar-label {
    font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
    color: var(--text-dim); padding: 12px 8px 4px; font-weight: 600;
}

.sidebar-separator {
    height: 1px; background: var(--border); margin: 8px 8px 4px;
}

.nav-link {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; border-radius: 8px; text-decoration: none;
    color: var(--text-muted); font-size: 13px; font-weight: 500; transition: all 0.15s;
}
.nav-link:hover { background: var(--surface2); color: var(--text); }
.nav-link.active { background: rgba(58,122,238,0.1); color: var(--accent); }

.main-content { flex: 1; padding: 28px 32px; overflow-y: auto; }
.page-title {
    font-family: 'Syne', sans-serif; font-weight: 700; font-size: 22px;
    letter-spacing: -0.3px; margin-bottom: 20px;
}

/* Cards */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 20px; margin-bottom: 16px;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; gap: 12px;
}
.card-title { font-family: 'Syne', sans-serif; font-weight: 600; font-size: 15px; }

/* Toggle */
.toggle-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 0; border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-label { font-size: 13px; font-weight: 500; }
.toggle-desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.toggle-switch {
    width: 40px; height: 22px; background: #1a2a4e; border-radius: 20px;
    cursor: pointer; position: relative; border: none; transition: background 0.2s;
    flex-shrink: 0;
}
.toggle-switch.on { background: var(--accent); }
.toggle-switch::after {
    content: ''; position: absolute; top: 3px; left: 3px;
    width: 16px; height: 16px; background: #fff; border-radius: 50%;
    transition: transform 0.2s;
}
.toggle-switch.on::after { transform: translateX(18px); }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
    text-align: left; font-size: 10px; text-transform: uppercase;
    letter-spacing: 0.8px; color: var(--text-dim); padding: 8px 12px;
    border-bottom: 1px solid var(--border); font-weight: 600;
}
td {
    padding: 10px 12px; border-bottom: 1px solid var(--border);
    font-size: 13px; vertical-align: middle;
}
tr:hover td { background: var(--surface2); }

.post-title-cell { max-width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Badges */
.badge {
    display: inline-block; font-size: 10px; padding: 2px 8px;
    border-radius: 20px; font-weight: 600;
}
.badge-canva { background: rgba(167,139,250,0.1); color: var(--canva); }
.badge-manual { background: var(--surface2); color: var(--text-muted); }
.badge-featured { background: rgba(58,122,238,0.1); color: var(--accent); }
.badge-breaking { background: rgba(239,68,68,0.1); color: var(--red); }
.badge-unpublished { background: rgba(122,154,191,0.15); color: var(--text-muted); }
tr.row-unpublished { opacity: 0.55; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px; border-radius: 8px; font-size: 12px;
    font-weight: 500; cursor: pointer; border: 1px solid transparent;
    font-family: 'DM Sans', sans-serif; transition: all 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: #2a6ade; }
.btn-danger { background: transparent; color: var(--red); border-color: rgba(239,68,68,0.2); }
.btn-danger:hover { background: rgba(239,68,68,0.1); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--border-hover); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 11px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block; font-size: 12px; font-weight: 500;
    color: var(--text-muted); margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
    width: 100%; padding: 9px 12px; background: var(--bg);
    border: 1px solid var(--border); border-radius: 8px;
    color: var(--text); font-family: 'DM Sans', sans-serif; font-size: 13px;
    transition: border-color 0.15s; outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--accent); }
.form-textarea { resize: vertical; min-height: 100px; }
.form-select { cursor: pointer; }
.form-select option { background: var(--surface); }

/* Checkbox row */
.check-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.check-row input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }
.check-row label { font-size: 13px; cursor: pointer; }

/* Alert */
.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert-success { background: rgba(34,197,94,0.1); color: var(--green); border: 1px solid rgba(34,197,94,0.15); }

/* Login */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: var(--bg); padding: 20px;
}
.login-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; padding: 32px; width: 100%; max-width: 380px;
}
.login-logo {
    font-family: 'Syne', sans-serif; font-weight: 800; font-size: 24px;
    letter-spacing: -0.5px; text-align: center; margin-bottom: 4px;
}
.login-logo span { color: var(--accent); }
.login-subtitle {
    text-align: center; font-size: 12px; color: var(--text-muted);
    margin-bottom: 24px;
}
.login-error {
    background: rgba(239,68,68,0.1); color: var(--red);
    border: 1px solid rgba(239,68,68,0.15);
    padding: 8px 12px; border-radius: 8px; font-size: 13px;
    margin-bottom: 16px; text-align: center;
}

/* Image Editor */
.editor-layout {
    display: grid; grid-template-columns: 280px 1fr 280px; gap: 16px; align-items: start;
}
.editor-col { display: flex; flex-direction: column; gap: 12px; }
.editor-col-center { display: flex; flex-direction: column; align-items: center; }
.editor-panel { padding: 16px; }
.canvas-wrap {
    width: 100%; max-width: 420px; border-radius: 8px; overflow: hidden;
    box-shadow: 0 4px 24px rgba(0,0,0,.6); touch-action: none;
}
.align-buttons { display: flex; gap: 4px; }
.align-buttons .btn.active { background: rgba(58,122,238,0.15); border-color: var(--accent); color: var(--accent); }
.canvas-wrap canvas {
    width: 100%; height: auto; display: block; cursor: grab;
}
.canvas-wrap canvas.drag { cursor: grabbing; }

.upload-area {
    display: flex; align-items: center; gap: 10px;
    background: rgba(58,122,238,0.05); border: 2px dashed var(--border);
    border-radius: 8px; padding: 14px; cursor: pointer; width: 100%;
    font-size: 13px; color: var(--accent2); transition: all .2s;
}
.upload-area:hover { background: rgba(58,122,238,0.1); border-color: var(--accent); }
.upload-area.loaded { border-color: var(--green); color: var(--green); background: rgba(34,197,94,0.05); }
.upload-icon { font-size: 18px; }
.upload-text { font-size: 12px; }

.form-range {
    width: 100%; accent-color: var(--accent); cursor: pointer;
    height: 4px; background: var(--border); border-radius: 4px;
    -webkit-appearance: none; appearance: none; outline: none;
}
.form-range::-webkit-slider-thumb {
    -webkit-appearance: none; width: 16px; height: 16px;
    background: var(--accent); border-radius: 50%; cursor: pointer;
}

.editor-fit-buttons {
    display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px;
}

.editor-actions {
    display: flex; gap: 8px; justify-content: center;
}

.editor-hint {
    color: var(--text-dim); font-size: 11px; margin-top: 10px;
    text-align: center; line-height: 1.8;
}

.color-preview {
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: 6px; padding: 8px 10px; font-size: 18px;
    line-height: 1.4; letter-spacing: 1px; min-height: 36px;
    word-break: break-all;
}

.color-swatches {
    display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px;
}
.color-swatch {
    width: 28px; height: 28px; border-radius: 6px; border: 2px solid transparent;
    cursor: pointer; transition: all .15s; position: relative;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(58,122,238,0.3); }

.font-list {
    display: flex; flex-direction: column; gap: 4px; margin-top: 4px;
}
.font-option {
    display: flex; align-items: center; padding: 6px 10px; border-radius: 6px;
    border: 1px solid transparent; background: none; cursor: pointer;
    color: var(--text); font-size: 15px; transition: all .15s; text-align: left;
}
.font-option:hover { background: var(--surface2); }
.font-option.active { border-color: var(--accent); background: rgba(58,122,238,0.1); }

.overlay-or {
    display: flex; align-items: center; gap: 10px; margin: 10px 0;
}
.overlay-or::before, .overlay-or::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
}
.overlay-or-text {
    font-size: 11px; color: var(--text-dim); white-space: nowrap;
}
.overlay-list {
    margin-top: 12px; display: flex; flex-direction: column; gap: 4px;
    border-top: 1px solid var(--border); padding-top: 10px;
}
.overlay-list-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 5px 8px; border-radius: 6px; background: var(--bg);
    font-size: 12px;
}
.overlay-list-name {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; margin-right: 8px;
}

/* Media Picker */
.media-search { margin-bottom: 10px; }

.media-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px; max-height: 320px; overflow-y: auto;
    padding: 4px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--bg);
}

.media-item {
    display: flex; flex-direction: column; align-items: center;
    background: none; border: 2px solid transparent; border-radius: 8px;
    padding: 4px; cursor: pointer; transition: all .15s; overflow: hidden;
}
.media-item:hover { border-color: var(--border-hover); background: var(--surface2); }
.media-item.selected { border-color: var(--accent); background: rgba(58,122,238,0.1); }

.media-item img {
    width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px;
    background: var(--surface2);
}
.media-item-name {
    font-size: 10px; color: var(--text-muted); margin-top: 4px;
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    text-align: center;
}

.media-selected {
    display: flex; align-items: center; gap: 12px;
    background: var(--surface2); border-radius: 8px; padding: 8px;
    margin-bottom: 10px;
}
.media-selected img {
    width: 64px; height: 64px; object-fit: cover; border-radius: 6px;
}
.media-selected-info {
    display: flex; flex-direction: column; gap: 4px;
}
.media-selected-name {
    font-size: 12px; color: var(--text); font-weight: 500;
}

@media (max-width: 960px) {
    .editor-layout { grid-template-columns: 1fr; }
    .editor-col-center { order: -1; }
    .media-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
    .addpost-layout { grid-template-columns: 1fr; }
}

/* Add Post layout */
.addpost-layout {
    display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
    align-items: start;
}
.addpost-col-left { min-width: 0; }
.addpost-col-right { min-width: 0; }

.addpost-meta-row { display: flex; gap: 12px; }
.addpost-checks-row { display: flex; gap: 20px; margin-top: 8px; }

.media-grid-large {
    max-height: 600px;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

/* Post preview — mimics front-end PostCard */
.post-preview {
    background: #0d0d1a; border-radius: 12px; overflow: hidden;
    border: 1px solid rgba(255,255,255,.06); font-family: 'DM Sans', system-ui, sans-serif;
}
.post-preview-card { padding: 0; }
.post-preview-top {
    display: flex; gap: 12px; padding: 16px;
}
.post-preview-body { flex: 1; min-width: 0; }
.post-preview-meta {
    display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px;
}
.post-preview-tag {
    font-size: 10px; font-weight: 600; text-transform: uppercase;
    letter-spacing: .5px; padding: 2px 8px; border-radius: 4px;
    background: rgba(91,110,245,.15); color: #7c8cf8;
}
.post-preview-breaking {
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    padding: 2px 8px; border-radius: 4px;
    background: rgba(211,47,47,.2); color: #ef5350;
    animation: pulse-break 1.5s infinite;
}
@keyframes pulse-break {
    0%, 100% { opacity: 1; }
    50% { opacity: .6; }
}
.post-preview-featured {
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    padding: 2px 8px; border-radius: 4px;
    background: rgba(255,214,0,.15); color: #ffd600;
}
.post-preview-title {
    font-size: 16px; font-weight: 700; color: #e8e8f0;
    line-height: 1.3; margin-bottom: 6px;
}
.post-preview-content {
    font-size: 13px; color: #9898b0; line-height: 1.5;
}
.post-preview-thumb {
    width: 90px; height: 90px; border-radius: 8px; overflow: hidden;
    flex-shrink: 0; background: #1a1a2e;
}
.post-preview-thumb img {
    width: 100%; height: 100%; object-fit: cover;
}
.post-preview-thumb-empty {
    display: flex; align-items: center; justify-content: center;
    font-size: 32px;
}
.post-preview-footer {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 16px; border-top: 1px solid rgba(255,255,255,.04);
    font-size: 11px; color: #6b6b88;
}
.post-preview-source { font-weight: 600; }

.post-preview {
    cursor: pointer; transition: all .2s;
}
.post-preview:hover { opacity: .92; }

.post-preview-img-expanded {
    width: 100%; overflow: hidden;
}
.post-preview-img-expanded img {
    width: 100%; display: block;
}
.post-preview-content-expanded {
    padding: 14px 16px; font-size: 14px; color: #c8c8d8;
    line-height: 1.6; white-space: pre-wrap;
}
.post-preview-expand-hint {
    font-size: 10px; color: #4a4a68; margin-left: auto;
}

/* Post title link */
.post-title-link {
    color: var(--text); text-decoration: none; transition: color .15s;
}
.post-title-link:hover { color: var(--accent); }

/* Modal */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.6);
    z-index: 1000; backdrop-filter: blur(2px);
}
.modal-dialog {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 14px; width: 90%; max-width: 860px; max-height: 85vh;
    display: flex; flex-direction: column; z-index: 1001;
    box-shadow: 0 8px 40px rgba(0,0,0,.5);
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-title {
    font-family: 'Syne', sans-serif; font-weight: 600; font-size: 15px;
}
.modal-close {
    background: none; border: none; color: var(--text-muted); font-size: 18px;
    cursor: pointer; padding: 4px 8px; border-radius: 6px; transition: all .15s;
}
.modal-close:hover { background: var(--surface2); color: var(--text); }
.modal-body {
    padding: 20px; overflow-y: auto; flex: 1;
}
.modal-footer {
    display: flex; align-items: center; justify-content: flex-end; gap: 8px;
    padding: 14px 20px; border-top: 1px solid var(--border);
}
.modal-columns {
    display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}
.modal-col-label {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px;
    color: var(--text-dim); font-weight: 600; margin-bottom: 10px;
    padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.modal-meta {
    display: flex; gap: 12px; margin-top: 4px;
}

@media (max-width: 768px) {
    .modal-dialog { width: 95%; max-width: none; }
    .modal-columns { grid-template-columns: 1fr; }
    .modal-meta { flex-direction: column; }
}

/* Pagination */
.pagination {
    display: flex; align-items: center; gap: 4px;
    padding: 14px 0 4px; justify-content: center;
}
.pagination .btn-primary { pointer-events: none; }
.pagination .form-select { font-size: 12px; padding: 4px 8px; }

/* Posts filters */
.posts-filters {
    display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center;
}

/* Feeds */
.feed-filter {
    display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap;
}
.feed-name { font-weight: 500; font-size: 13px; }
.feed-url {
    font-size: 11px; color: var(--text-dim); max-width: 320px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.feed-time { font-size: 12px; color: var(--text-muted); }
.feed-add-form {
    background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
    padding: 16px; margin-bottom: 16px;
}

/* Video editor */
.video-editor-layout {
    display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
    align-items: start;
}
.video-editor-col-left { min-width: 0; }
.video-editor-col-right { min-width: 0; }

.video-platform-badge {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 6px; padding: 4px 12px; font-size: 13px;
    color: var(--accent2); margin-bottom: 8px;
}
.platform-icon { font-size: 16px; }

.video-preview-wrapper {
    position: relative; width: 100%; border-radius: 8px; overflow: hidden;
    background: #000;
}
.video-preview-iframe {
    width: 100%; aspect-ratio: 16/9; border: none; display: block;
}
.video-preview-iframe.video-iframe-vertical { aspect-ratio: 9/16; max-height: 500px; }
.video-preview-iframe.video-iframe-twitter { aspect-ratio: auto; min-height: 300px; height: 450px; }

.video-preview-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    object-fit: contain; pointer-events: none; z-index: 2;
}
.video-preview-placeholder {
    display: flex; align-items: center; justify-content: center;
    min-height: 200px; background: var(--surface2); border-radius: 8px;
    color: var(--text-dim); font-size: 13px;
}
.time-input-row {
    display: flex; align-items: center; gap: 4px;
}
.time-input {
    width: 70px !important; text-align: center;
}
.time-sep {
    font-size: 18px; font-weight: bold; color: var(--text-muted);
}

.video-post-preview {
    padding: 12px; background: var(--surface2); border-radius: 8px;
}

@media (max-width: 900px) {
    .video-editor-layout { grid-template-columns: 1fr; }
}

/* Blazor overrides */
.valid.modified:not([type=checkbox]) { outline: none; }
.invalid { outline: 1px solid var(--red); }
#blazor-error-ui { display: none; }
