﻿/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --sidebar-bg: #0f172a;
    --sidebar-hover: rgba(255,255,255,0.08);
    --sidebar-active: #2563eb;
    --accent: #f59e0b;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #f1f5f9;
    --card: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-sm: #64748b;
    --radius: 10px;
    --shadow: 0 1px 4px rgba(0,0,0,.10);
    --shadow-md: 0 4px 12px rgba(0,0,0,.12);
}

body { font-family: 'Segoe UI', system-ui, sans-serif; color: var(--text); background: var(--bg); }

/* ===== LOGIN ===== */
.login-screen {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
}
.login-box {
    background: var(--card); border-radius: 16px; padding: 2.5rem;
    width: 100%; max-width: 400px; box-shadow: var(--shadow-md);
}
.login-logo { font-size: 1.6rem; font-weight: 800; color: var(--text); margin-bottom: .25rem; }
.login-logo span { color: var(--accent); }
.login-sub { color: var(--text-sm); margin-bottom: 2rem; font-size: .9rem; }
.field { margin-bottom: 1.25rem; }
.field label { display: block; font-weight: 600; font-size: .875rem; margin-bottom: .4rem; color: var(--text); }
.field input, .field textarea, .field select {
    width: 100%; padding: .7rem 1rem; border: 1.5px solid var(--border);
    border-radius: 8px; font-size: 1rem; font-family: inherit;
    transition: border-color .2s, box-shadow .2s;
    background: #fff; color: var(--text);
}
.field input:focus, .field textarea:focus, .field select:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.field textarea { resize: vertical; }
.err-msg { color: var(--danger); font-size: .85rem; margin-top: .75rem; }
.full { width: 100%; }
.forgot-link { font-size: .85rem; color: var(--primary); text-decoration: none; }
.forgot-link:hover { text-decoration: underline; }
.forgot-desc { font-size: .85rem; color: var(--text-sm); margin-bottom: 1rem; }

/* ===== LAYOUT ===== */
.cms-layout {
    min-height: 100vh;
    position: relative;
}

/* ===== SIDEBAR ===== */
.sidebar {
    background: var(--sidebar-bg); color: white;
    display: flex; flex-direction: column;
    position: fixed; left: 0; top: 0; bottom: 0; width: 240px;
    overflow-y: auto; z-index: 100;
}
.sidebar-logo {
    padding: 1.5rem 1.25rem; font-size: 1.25rem; font-weight: 800;
    color: white; border-bottom: 1px solid rgba(255,255,255,.08);
    letter-spacing: -.5px;
}
.sidebar-logo span { color: var(--accent); }
.sidebar-nav { flex: 1; padding: .75rem 0; }
.nav-group-label {
    padding: .75rem 1.25rem .3rem;
    font-size: .65rem; text-transform: uppercase; letter-spacing: .1em;
    color: #475569; font-weight: 700;
}
.nav-item {
    display: flex; align-items: center; gap: .5rem;
    padding: .6rem 1.25rem; color: #94a3b8;
    cursor: pointer; font-size: .875rem;
    border-left: 3px solid transparent;
    transition: background .15s, color .15s;
    text-decoration: none;
    position: relative;
}
.nav-item:hover { background: var(--sidebar-hover); color: white; }
.nav-item.active { background: rgba(37,99,235,.2); color: white; border-left-color: var(--primary); }
.nav-badge {
    background: var(--danger); color: white; border-radius: 9999px;
    font-size: .65rem; padding: .1rem .4rem; font-weight: 700; margin-left: auto;
}
.sidebar-footer {
    padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,.08);
    display: flex; align-items: center; justify-content: space-between;
}
.sidebar-user { color: #94a3b8; font-size: .8rem; display: flex; align-items: center; gap: .4rem; }
.user-dot { color: var(--success); font-size: .6rem; }

/* ===== MAIN ===== */
.cms-main { margin-left: 240px; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
    height: 60px; background: white; border-bottom: 1px solid var(--border);
    padding: 0 2rem; display: flex; align-items: center;
    justify-content: space-between; position: sticky; top: 0; z-index: 50;
    box-shadow: var(--shadow);
}
.cms-layout.preview-open .topbar {
    position: sticky;
    /* topbar jest sticky w obrębie cms-main, nie potrzebuje right */
}
.topbar h2 { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.topbar-actions { display: flex; gap: .75rem; }
.cms-content { padding: 2rem; flex: 1; }

/* ===== TABS ===== */
.tab { display: none; }
.tab.active { display: block; }

/* ===== BUTTONS ===== */
.btn-primary {
    display: inline-block; padding: .65rem 1.4rem;
    background: var(--primary); color: white; border: none;
    border-radius: 8px; font-weight: 600; font-size: .9rem;
    cursor: pointer; transition: background .2s, box-shadow .2s;
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--shadow-md); }
.btn-ghost {
    display: inline-block; padding: .6rem 1.2rem;
    background: transparent; color: #94a3b8; border: none;
    border-radius: 8px; font-size: .85rem; cursor: pointer;
    transition: color .2s, background .2s;
}
.btn-ghost:hover { color: white; background: rgba(255,255,255,.08); }
.btn-save {
    padding: .55rem 1.2rem; background: var(--success); color: white;
    border: none; border-radius: 8px; font-weight: 600; font-size: .875rem;
    cursor: pointer; transition: background .2s;
}
.btn-save:hover { background: #059669; }
.btn-save-alt {
    padding: .55rem 1.2rem; background: var(--primary); color: white;
    border: none; border-radius: 8px; font-weight: 600; font-size: .875rem;
    cursor: pointer;
}
.btn-preview {
    padding: .55rem 1.2rem; background: #f8fafc; color: var(--text);
    border: 1.5px solid var(--border); border-radius: 8px;
    font-size: .875rem; font-weight: 600; text-decoration: none;
    transition: background .2s; white-space: nowrap;
}
.btn-preview:hover { background: var(--primary); color: white; border-color: var(--primary); }
.btn-sm { padding: .35rem .85rem; font-size: .8rem; border-radius: 6px; border: none; cursor: pointer; font-weight: 600; }
.btn-edit { background: #eff6ff; color: var(--primary); }
.btn-edit:hover { background: var(--primary); color: white; }
.btn-del { background: #fef2f2; color: var(--danger); }
.btn-del:hover { background: var(--danger); color: white; }
.btn-toggle-on { background: #ecfdf5; color: var(--success); }
.btn-toggle-off { background: #fef3c7; color: #92400e; }

/* ===== EDITOR CARDS ===== */
.editor-card {
    background: var(--card); border-radius: var(--radius);
    box-shadow: var(--shadow); margin-bottom: 1.5rem; overflow: hidden;
}
.card-header {
    padding: 1rem 1.5rem; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    background: #fafafa; font-weight: 700; font-size: .95rem;
}
.editor-card > .field,
.editor-card > .field-row { padding: 0 1.5rem; margin-bottom: 1.25rem; }
.editor-card > .field:first-of-type, .editor-card > .field-row:first-of-type { margin-top: 1.25rem; }
.editor-card > .field:last-of-type, .editor-card > .field-row:last-of-type { margin-bottom: 1.5rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ===== WYSIWYG ===== */
.wysiwyg-wrap { border: 1.5px solid var(--border); border-radius: 8px; overflow: hidden; }
.wysiwyg-bar {
    background: #f8fafc; border-bottom: 1px solid var(--border);
    padding: .4rem .75rem; display: flex; align-items: center; gap: .2rem; flex-wrap: wrap;
}
.wysiwyg-bar button {
    padding: .2rem .6rem; border: 1px solid var(--border); border-radius: 4px;
    background: white; cursor: pointer; font-size: .82rem; transition: background .15s;
    line-height: 1.4;
}
.wysiwyg-bar button:hover { background: var(--primary); color: white; border-color: var(--primary); }
.wysiwyg-bar .sep { width: 1px; height: 20px; background: var(--border); margin: 0 .3rem; }
.wysiwyg-body {
    min-height: 220px; padding: 1rem; outline: none; font-size: .95rem;
    line-height: 1.7; color: var(--text);
}
.wysiwyg-body p { margin-bottom: .75rem; }
.wysiwyg-body h3 { margin-bottom: .5rem; font-size: 1.05rem; }

/* ===== STATS EDITOR ===== */
.stats-editor-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.25rem; padding: 1.5rem; }
.stat-editor-item {
    border: 1.5px solid var(--border); border-radius: 10px;
    padding: 1.25rem 1rem 1rem; text-align: center;
    background: var(--bg);
}
.stat-editor-item .stat-box-label {
    font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
    color: var(--text-sm); margin-bottom: .75rem; padding-bottom: .5rem;
    border-bottom: 1px solid var(--border);
}
.stat-editor-item .stat-preview {
    font-size: 1.6rem; font-weight: 700; color: var(--primary);
    line-height: 1; margin-bottom: .75rem;
    font-family: inherit;
}
.stat-editor-item label { font-size: .7rem; font-weight: 600; color: var(--text-sm); margin-bottom: .3rem; display: block; text-align: left; }
.stat-editor-item input {
    width: 100%; border: 1px solid var(--border); border-radius: 6px;
    padding: .45rem .6rem; font-size: .9rem; text-align: center;
    margin-bottom: .65rem; background: white;
    transition: border-color .15s;
}
.stat-editor-item input:last-child { margin-bottom: 0; }
.stat-editor-item input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.08); }

/* ===== DASHBOARD GRID ===== */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1.25rem; }
.dash-card {
    background: white; border-radius: var(--radius); padding: 1.5rem;
    box-shadow: var(--shadow); display: flex; align-items: center; gap: 1rem;
    transition: box-shadow .2s;
}
.dash-card:hover { box-shadow: var(--shadow-md); }
.dash-icon { font-size: 2rem; }
.dash-num { font-size: 2rem; font-weight: 800; color: var(--primary); }
.dash-lbl { font-size: .8rem; color: var(--text-sm); }

/* ===== DATA TABLE ===== */
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th {
    padding: .75rem 1rem; text-align: left; font-weight: 600;
    color: var(--text-sm); background: #f8fafc; border-bottom: 2px solid var(--border);
}
.data-table td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f8fafc; }
.table-wrap { overflow-x: auto; }

/* ===== PORTFOLIO LIST ===== */
.portfolio-editor-item {
    display: flex; align-items: center; gap: 1rem;
    padding: 1rem 1.5rem; border-bottom: 1px solid var(--border);
}
.portfolio-editor-item:last-child { border-bottom: none; }
.portfolio-thumb {
    width: 80px; height: 56px; border-radius: 6px; overflow: hidden;
    background: var(--bg); flex-shrink: 0; border: 1px solid var(--border);
}
.portfolio-thumb img { width: 100%; height: 100%; object-fit: cover; }
.portfolio-thumb-empty { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--text-sm); font-size: .8rem; }
.portfolio-info { flex: 1; min-width: 0; }
.portfolio-info strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.portfolio-info span { font-size: .8rem; color: var(--text-sm); }
.portfolio-actions { display: flex; gap: .5rem; flex-shrink: 0; }

/* ===== BADGES ===== */
.badge { display: inline-block; padding: .2rem .6rem; border-radius: 9999px; font-size: .75rem; font-weight: 600; }
.badge-new { background: #dbeafe; color: var(--primary); }
.badge-read { background: #f0fdf4; color: var(--success); }
.badge-done { background: #f1f5f9; color: var(--text-sm); }
.badge-rejected { background: #fef2f2; color: var(--danger); }
.badge-active { background: #ecfdf5; color: var(--success); }
.badge-inactive { background: #f8fafc; color: var(--text-sm); }
.badge-pending { background: #fef9c3; color: #92400e; }

/* ===== DETAIL ROW ===== */
.detail-row td { padding: 0 !important; }
.detail-card { background: #f8fafc; padding: 1rem 1.5rem; border-top: 1px solid var(--border); }
.detail-card p { margin-bottom: .4rem; font-size: .85rem; }
.detail-card strong { color: var(--text); }
.detail-files { display: flex; gap: .5rem; margin-top: .5rem; flex-wrap: wrap; }
.file-link {
    display: inline-flex; align-items: center; gap: .25rem;
    padding: .25rem .75rem; background: #eff6ff; color: var(--primary);
    border-radius: 9999px; font-size: .8rem; text-decoration: none; font-weight: 600;
}
.file-link:hover { background: var(--primary); color: white; }

/* ===== MODAL ===== */
.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 9000; overflow: auto; }
.modal.show { display: flex; align-items: flex-start; justify-content: center; padding-top: 5vh; }
.modal-box {
    background: white; border-radius: 14px; width: 90%; max-width: 540px;
    box-shadow: 0 20px 40px rgba(0,0,0,.2); margin-bottom: 2rem;
}
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 1.1rem; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-sm); }
.modal-close:hover { color: var(--text); }
.modal-foot { display: flex; gap: .75rem; justify-content: flex-end; padding-top: 1rem; border-top: 1px solid var(--border); margin-top: .5rem; }

/* ===== TOAST ===== */
.toast {
    position: fixed; bottom: 2rem; right: 2rem;
    padding: .85rem 1.5rem; border-radius: 10px;
    background: var(--success); color: white;
    box-shadow: var(--shadow-md); font-weight: 600;
    transform: translateY(120px); transition: transform .3s;
    z-index: 9999;
}
.toast.show { transform: translateY(0); }
.toast.err { background: var(--danger); }

/* ===== MISC ===== */
.empty-state { padding: 3rem; text-align: center; color: var(--text-sm); font-size: .9rem; }
.content-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.editor-card form { padding: 1.5rem; }

/* ===== PREVIEW PANE ===== */
.preview-pane {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 48%;
    background: white;
    border-left: 2px solid var(--border);
    display: none;
    flex-direction: column;
    z-index: 90;
    box-shadow: -4px 0 20px rgba(0,0,0,.12);
}
.preview-pane.open { display: flex; }
.cms-layout.preview-open .cms-main { margin-right: 48%; }
.cms-layout.preview-open .topbar { right: 48%; }
.preview-bar {
    height: 48px; background: var(--sidebar-bg); color: white;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1rem; flex-shrink: 0;
}
.preview-title { font-size: .85rem; font-weight: 600; color: #94a3b8; }
.preview-bar-actions { display: flex; gap: .4rem; }
.preview-btn {
    padding: .3rem .75rem; background: rgba(255,255,255,.1); color: #cbd5e1;
    border: 1px solid rgba(255,255,255,.15); border-radius: 6px;
    font-size: .8rem; cursor: pointer; transition: background .15s;
}
.preview-btn:hover { background: rgba(255,255,255,.2); color: white; }
.preview-close { color: #f87171; }
.preview-close:hover { background: rgba(248,113,113,.2); }
#previewIframe { flex: 1; width: 100%; border: none; }
#togglePreviewBtn.active { background: var(--primary); color: white; border-color: var(--primary); }