/* Scenar Creator v3 — Main Stylesheet */

:root {
    --header-bg: #1e293b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #22c55e;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --bg: #f8fafc;
    --white: #ffffff;
    --sidebar-width: 280px;
    --header-height: 56px;
    --tab-height: 40px;
    --grid-row-height: 30px;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
}

/* Header */
.header {
    height: var(--header-height);
    background: var(--header-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    color: white;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-title {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.header-version {
    font-size: 11px;
    background: rgba(255,255,255,0.15);
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Tabs */
.tabs {
    height: var(--tab-height);
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex;
    padding: 0 20px;
    gap: 0;
}

.tab {
    padding: 0 16px;
    height: 100%;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    font-family: inherit;
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: rgba(255,255,255,0.12);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.2);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

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

.btn-xs {
    padding: 4px 10px;
    font-size: 11px;
    background: var(--bg);
    color: var(--text-light);
    border: 1px solid var(--border);
}

.btn-xs:hover {
    background: var(--border);
    color: var(--text);
}

.btn-block {
    width: 100%;
}

/* Layout */
.tab-content {
    height: calc(100vh - var(--header-height) - var(--tab-height));
    overflow: hidden;
}

.tab-content.hidden {
    display: none;
}

.app-layout {
    display: flex;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--white);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 16px;
}

.sidebar-section {
    margin-bottom: 20px;
}

.sidebar-heading {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
    margin-bottom: 10px;
    font-weight: 600;
}

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

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-light);
    margin-bottom: 4px;
}

.form-group input[type="text"],
.form-group input[type="date"],
.form-group input[type="time"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    background: var(--white);
    color: var(--text);
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.form-row {
    display: flex;
    gap: 10px;
}

.form-row .form-group {
    flex: 1;
}

/* Program type rows */
.type-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    padding: 6px 8px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.type-row input[type="color"] {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 0;
    background: none;
}

.type-row input[type="text"] {
    flex: 1;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: inherit;
}

.type-row input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
}

.type-remove {
    width: 22px;
    height: 22px;
    border: none;
    background: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.type-remove:hover {
    background: var(--danger);
    color: white;
}

/* Canvas */
.canvas-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
}

.canvas-header {
    display: flex;
    padding: 0 0 0 60px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    min-height: 36px;
    align-items: stretch;
}

.canvas-header .day-header {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    border-left: 1px solid var(--border);
    padding: 8px;
}

.canvas-header .day-header:first-child {
    border-left: none;
}

.canvas-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
}

.canvas {
    display: flex;
    position: relative;
    min-height: 600px;
}

.time-axis {
    width: 60px;
    min-width: 60px;
    position: relative;
    background: var(--white);
    border-right: 1px solid var(--border);
}

.time-label {
    position: absolute;
    right: 8px;
    font-size: 11px;
    color: var(--text-light);
    transform: translateY(-50%);
    font-variant-numeric: tabular-nums;
}

.day-columns {
    flex: 1;
    display: flex;
    position: relative;
}

.day-column {
    flex: 1;
    position: relative;
    border-left: 1px solid var(--border);
    min-width: 200px;
}

.day-column:first-child {
    border-left: none;
}

/* Grid lines */
.grid-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border);
    pointer-events: none;
}

.grid-line.hour {
    background: var(--border);
}

.grid-line.half {
    background: #f1f5f9;
}

/* Schedule blocks */
.schedule-block {
    position: absolute;
    left: 4px;
    right: 4px;
    border-radius: 6px;
    padding: 6px 8px;
    cursor: grab;
    overflow: hidden;
    transition: box-shadow 0.15s;
    z-index: 10;
    display: flex;
    flex-direction: column;
    min-height: 20px;
    user-select: none;
    touch-action: none;
}

.schedule-block:hover {
    box-shadow: var(--shadow-lg);
    z-index: 20;
}

.schedule-block:active {
    cursor: grabbing;
}

.schedule-block .block-color-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: 6px 0 0 6px;
}

.schedule-block .block-title {
    font-size: 12px;
    font-weight: 600;
    color: white;
    line-height: 1.2;
    padding-left: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.schedule-block .block-time {
    font-size: 10px;
    color: rgba(255,255,255,0.8);
    padding-left: 4px;
}

.schedule-block .block-responsible {
    font-size: 10px;
    color: rgba(255,255,255,0.7);
    padding-left: 4px;
    margin-top: auto;
}

.schedule-block.light-bg .block-title {
    color: var(--text);
}

.schedule-block.light-bg .block-time {
    color: var(--text-light);
}

.schedule-block.light-bg .block-responsible {
    color: var(--text-light);
}

/* Resize handle */
.schedule-block .resize-handle {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 8px;
    cursor: s-resize;
    background: transparent;
}

.schedule-block:hover .resize-handle {
    background: rgba(0,0,0,0.1);
    border-radius: 0 0 6px 6px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 420px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    width: 30px;
    height: 30px;
    border: none;
    background: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--bg);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: space-between;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    z-index: 2000;
    transition: opacity 0.3s, transform 0.3s;
    box-shadow: var(--shadow-lg);
}

.toast.hidden {
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
}

.toast.success {
    background: var(--success);
    color: white;
}

.toast.error {
    background: var(--danger);
    color: white;
}

.toast.info {
    background: var(--accent);
    color: white;
}

/* Documentation */
.docs-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 32px 24px;
    overflow-y: auto;
    height: 100%;
}

.docs-container h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--text);
}

.docs-container h3 {
    font-size: 16px;
    font-weight: 600;
    margin-top: 24px;
    margin-bottom: 12px;
    color: var(--text);
}

.docs-container p {
    margin-bottom: 12px;
    color: var(--text-light);
    line-height: 1.7;
}

.docs-container ul,
.docs-container ol {
    margin-bottom: 12px;
    padding-left: 24px;
    color: var(--text-light);
}

.docs-container li {
    margin-bottom: 6px;
    line-height: 1.6;
}

.docs-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 13px;
}

.docs-table th,
.docs-table td {
    padding: 8px 12px;
    text-align: left;
    border: 1px solid var(--border);
}

.docs-table th {
    background: var(--bg);
    font-weight: 600;
    color: var(--text);
}

.docs-table td {
    color: var(--text-light);
}

/* Canvas click area for creating blocks */
.day-column-click-area {
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* Scrollbar */
.canvas-scroll::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.canvas-scroll::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.canvas-scroll::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.canvas-scroll::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* Sidebar buttons in non-header context */
.sidebar .btn-secondary {
    background: var(--bg);
    color: var(--text-light);
    border: 1px solid var(--border);
}

.sidebar .btn-secondary:hover {
    background: var(--border);
    color: var(--text);
}

/* ============================================================
   v4 — Horizontal Canvas (X=time, Y=days)
   ============================================================ */

.canvas-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
}

.canvas-scroll-area {
    flex: 1;
    overflow: auto;
    padding: 12px 16px;
}

/* Time axis row */
.time-axis-row {
    display: flex;
    align-items: flex-end;
    margin-bottom: 2px;
}

.time-corner {
    background: transparent;
    flex-shrink: 0;
}

.time-tick {
    position: absolute;
    top: 4px;
    font-size: 10px;
    color: var(--text-light);
    transform: translateX(-50%);
    font-variant-numeric: tabular-nums;
    pointer-events: none;
    white-space: nowrap;
}

/* Day rows */
.day-rows {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.day-row {
    display: flex;
    align-items: stretch;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
}

/* Highlight the row being dragged over */
.day-timeline.drag-target {
    background: #eff6ff;
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

/* Floating ghost shown during cross-day drag */
.drag-ghost {
    border-radius: 4px;
    pointer-events: none;
    user-select: none;
}

.day-label {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 10px 0 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-light);
    background: #f8fafc;
    border-right: 1px solid var(--border);
    flex-shrink: 0;
    white-space: nowrap;
}

.day-timeline {
    flex: 1;
    position: relative;
    background: var(--white);
    cursor: crosshair;
    overflow: hidden;
}

/* Hour grid lines in timeline */
.grid-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border);
    pointer-events: none;
    z-index: 1;
}

/* Block element (horizontal) */
.block-el {
    position: absolute;
    border-radius: 4px;
    overflow: hidden;
    cursor: grab;
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0,0,0,0.18);
    transition: box-shadow 0.12s;
    user-select: none;
    touch-action: none;
    display: flex;
    align-items: center;
}

.block-el:hover {
    box-shadow: 0 3px 8px rgba(0,0,0,0.25);
    z-index: 20;
}

.block-el:active {
    cursor: grabbing;
}

.block-el.overnight {
    opacity: 0.85;
    border-right: 3px dashed rgba(255,255,255,0.5);
}

.block-inner {
    padding: 2px 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    width: 100%;
}

.block-title {
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.block-time {
    font-size: 9px;
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

/* Resize handle on right edge — explicit element, always correct cursor */
.block-resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 8px;
    cursor: col-resize;
    z-index: 5;
    border-radius: 0 4px 4px 0;
    background: transparent;
    transition: background 0.12s;
}

.block-el:hover .block-resize-handle {
    background: rgba(255,255,255,0.25);
}

/* Duration row (hours + minutes) */
.duration-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.duration-field {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.duration-field input[type="number"] {
    width: 60px;
    text-align: center;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text);
    background: var(--white);
}

.duration-field input[type="number"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.duration-unit {
    font-size: 12px;
    color: var(--text-light);
    white-space: nowrap;
}

/* Responsible in block */
.block-responsible {
    font-size: 9px;
    opacity: 0.75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.1;
    font-style: italic;
}

/* Docs version line */
.docs-version {
    color: var(--text-light);
    font-size: 12px;
    margin-bottom: 16px;
}

.docs-container h3 {
    margin-top: 20px;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
}

.docs-container h2 {
    font-size: 20px;
    margin-bottom: 4px;
    color: var(--header-bg);
}

/* Modal footer with left/right split */
.modal-footer-left {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* Outline danger button (for "Smazat sérii") */
.btn-danger-outline {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.btn-danger-outline:hover {
    background: var(--danger);
    color: white;
}

/* Series checkbox row */
.series-row {
    margin-top: 4px;
    padding: 10px 12px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-sm);
}

.series-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    margin-bottom: 0 !important;
}

.series-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

.series-hint {
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-light);
    padding-left: 24px;
}

.hidden {
    display: none !important;
}

/* Time text inputs (replacing type=time to avoid AM/PM) */
.time-input {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.5px;
    text-align: center;
}

.time-input.input-error {
    border-color: var(--danger) !important;
    background: #fff5f5;
}
