/* ============================================
   CSS VARIABLES
============================================ */
:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f0f1a;
    --bg-card: #1e1e32;
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --accent: #4f8cff;
    --accent-hover: #3a7be8;
    --success: #4caf50;
    --warning: #ff9800;
    --danger: #f44336;
    --border: #2a2a4a;
    --font-main: 'Inter', sans-serif;
    --font-timer: 'Nunito', sans-serif;
    --radius: 8px;
    --transition: 0.2s ease;
}

/* ============================================
   RESET & BASE
============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-y: auto;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    transition: var(--transition);
}

input, select {
    font-family: inherit;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius);
    outline: none;
}

input:focus, select:focus {
    border-color: var(--accent);
}

/* ============================================
   MAIN LAYOUT
============================================ */
.app-container {
    display: grid;
    grid-template-columns: auto 1fr auto;
    height: 100vh;
    gap: 0;
}

/* ============================================
   LEFT PANEL - PARAMÈTRES
============================================ */
.panel-left {
    width: 280px;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    transition: width 0.3s ease;
    overflow: hidden;
    position: relative;
    z-index: 500;
}

.panel-left.collapsed {
    width: 0;
    border-right: none;
}

.panel-left.collapsed .panel-content,
.panel-left.collapsed .panel-nav,
.panel-left.collapsed .panel-header {
    opacity: 0;
    pointer-events: none;
}

/* Onglet pour réouvrir */
.panel-tab {
    position: fixed;
    left: 0;
    top: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-left: none;
    border-radius: 0 8px 8px 0;
    padding: 12px 8px;
    cursor: pointer;
    z-index: 600;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.panel-tab:hover {
    background: var(--bg-tertiary);
    padding-right: 12px;
}

.panel-tab .tab-icon {
    font-size: 18px;
}

.panel-tab .tab-text {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

.panel-left.collapsed + .panel-tab,
.show-tab {
    display: flex;
}

.panel-right.collapsed ~ .panel-right-tab {
    display: flex;
}

/* Onglet pour panel-right */
.panel-right-tab {
    position: fixed;
    right: 0;
    top: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: 8px 0 0 8px;
    padding: 12px 8px;
    cursor: pointer;
    z-index: 600;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.panel-right-tab:hover {
    background: var(--bg-tertiary);
    padding-left: 12px;
}

.panel-right-tab .tab-icon {
    font-size: 18px;
}

.panel-right-tab .tab-text {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    min-height: 60px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px;
}

.logo-image {
    height: 45px;
    width: auto;
    object-fit: contain;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    display: none;
}

.logo-text {
    font-weight: 700;
    font-size: 16px;
    white-space: nowrap;
    transition: opacity 0.2s;
    display: none;
}

.btn-collapse {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px;
    border-radius: var(--radius);
    font-size: 18px;
}

.btn-collapse:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.panel-nav {
    padding: 12px 8px;
    border-bottom: 1px solid var(--border);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    background: transparent;
    width: 100%;
    text-align: left;
    font-size: 14px;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent);
    color: white;
}

.nav-item .icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.menu-label {
    white-space: nowrap;
    transition: opacity 0.2s;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    transition: opacity 0.2s;
}

.param-section {
    display: none;
    margin-bottom: 20px;
}

.param-section.active {
    display: block;
}

.param-section h3 {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 12px;
    margin-top: 16px;
    letter-spacing: 0.5px;
}

.param-section h3:first-child {
    margin-top: 0;
}

.param-group {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 8px;
}

.param-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.param-row:last-child {
    margin-bottom: 0;
}

.param-row-multi {
    gap: 8px;
}

.param-mini {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 4px;
}

.param-mini-label {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.param-number {
    width: 100%;
    padding: 6px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 13px;
    text-align: center;
}

.param-number:focus {
    border-color: var(--accent);
    outline: none;
}

.btn-warning {
    background: var(--warning) !important;
    color: #000 !important;
}

.btn-warning:hover {
    background: #e68900 !important;
}

/* Système de sauvegarde */
.save-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.save-actions .param-input {
    flex: 1;
    min-width: 0;
}

.btn-save {
    width: 40px !important;
    padding: 8px !important;
    flex-shrink: 0;
}

.saved-configs-container {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.saved-configs-header {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
}

.saved-configs-list {
    max-height: 150px;
    overflow-y: auto;
}

.saved-configs-list::-webkit-scrollbar {
    width: 6px;
}

.saved-configs-list::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

.saved-configs-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.saved-config-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}

.saved-config-item:last-child {
    border-bottom: none;
}

.saved-config-item:hover {
    background: var(--bg-tertiary);
}

.saved-config-item.selected {
    background: var(--accent);
    color: white;
}

.saved-config-name {
    flex: 1;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.saved-config-date {
    font-size: 10px;
    color: var(--text-secondary);
    margin-left: 8px;
}

.saved-config-item:hover .saved-config-date {
    display: none;
}

.saved-config-actions {
    display: none;
    gap: 4px;
}

.saved-config-item:hover .saved-config-actions {
    display: flex;
}

.saved-config-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px 6px;
    font-size: 12px;
    border-radius: 3px;
}

.saved-config-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.saved-config-btn.btn-delete:hover {
    background: var(--danger);
    color: white;
}

.saved-configs-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 11px;
    font-style: italic;
}

/* Alertes */
.alert-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 10px;
}

.alert-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.alert-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.btn-delete-alert {
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
}

.btn-delete-alert:hover {
    background: #c0392b;
}

.alert-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 8px;
}

.alert-row:last-child {
    margin-bottom: 0;
}

.alert-label {
    font-size: 11px;
    color: var(--text-secondary);
    min-width: 70px;
}

.alert-input-time {
    display: flex;
    gap: 4px;
    align-items: center;
}

.alert-input-time input {
    width: 40px;
    padding: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 12px;
    text-align: center;
}

.alert-input-time span {
    font-size: 10px;
    color: var(--text-secondary);
}

/* Checkbox label dans alertes */
.alert-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-secondary);
    cursor: pointer;
    min-width: 100px;
}

.alert-checkbox-label input[type="checkbox"] {
    cursor: pointer;
}

/* Drag Number Input */
.drag-number {
    cursor: ew-resize !important;
    user-select: none;
}

/* Masquer les flèches des inputs number avec drag-slider */
.drag-number::-webkit-inner-spin-button,
.drag-number::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.drag-number[type="number"] {
    -moz-appearance: textfield;
}

.drag-number:focus {
    cursor: text !important;
}

.drag-number.dragging {
    background: var(--accent-color) !important;
    color: white !important;
}

.param-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.param-input {
    width: 150px;
    padding: 6px 10px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 13px;
}

.param-input:focus {
    outline: none;
    border-color: var(--accent);
}

.param-sub {
    margin-top: 8px;
    padding-left: 20px;
    border-left: 2px solid var(--border);
}

.param-slider {
    width: 100px;
    margin-right: 8px;
}

.slider-value {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
    min-width: 40px;
}

.btn-file-pick {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-file-pick:hover {
    border-color: var(--accent);
    background: var(--border);
}

.style-mode-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 8px;
}

.style-mode-btn {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
    color: white;
}

.style-mode-btn:hover {
    border-color: var(--accent);
    background: var(--bg-tertiary);
}

.style-mode-btn.active {
    border-color: var(--accent);
    background: var(--accent);
    color: white;
}

.style-mode-btn .mode-icon {
    font-size: 18px;
    color: white;
}

.style-mode-btn .mode-icon.digital-icon {
    font-size: 14px;
    font-weight: bold;
    font-family: 'Roboto Mono', monospace;
}

.style-mode-btn .mode-icon.bar-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 18px;
}

.bar-container {
    width: 40px;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
}

.bar-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 50%;
    background: white;
    border-radius: 4px;
}

.style-mode-btn .mode-label {
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 600;
    color: white;
}

.btn-add-alert {
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    margin-top: 8px;
}

.btn-add-alert:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-system {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 8px;
    transition: var(--transition);
}

.btn-system:hover {
    background: var(--accent-hover);
}

.btn-system.btn-danger {
    background: var(--danger);
}

.btn-system.btn-danger:hover {
    background: #c62828;
}

/* Toggle Switch */
.toggle {
    position: relative;
    width: 44px;
    height: 24px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-tertiary);
    border-radius: 24px;
    cursor: pointer;
    transition: var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: var(--transition);
}

.toggle input:checked + .toggle-slider {
    background: var(--accent);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
    background: white;
}

/* Color Picker */
.color-picker {
    width: 36px;
    height: 28px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
}

/* Select */
.param-select {
    width: 120px;
    padding: 6px 10px;
    font-size: 13px;
}

/* ============================================
   CENTER PANEL - CONTRÔLE
============================================ */
.panel-center {
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    padding: 10px;
    gap: 0;
    overflow: hidden;
    height: 100%;
}

.control-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    border: 2px solid rgba(0, 0, 0, 0.3);
    transition: border-color 0.3s ease;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* États des zones */
.control-section.state-playing {
    border-color: var(--danger);
    box-shadow: 0 0 20px rgba(231, 76, 60, 0.2);
}

.control-section.state-paused {
    border-color: #FFB74D;
    box-shadow: 0 0 20px rgba(255, 183, 77, 0.3);
}

.control-section.state-text-showing {
    border-color: var(--danger);
    box-shadow: 0 0 20px rgba(231, 76, 60, 0.2);
}

.control-section.state-output-open {
    border-color: var(--danger);
    box-shadow: 0 0 20px rgba(244, 67, 54, 0.2);
}

/* Timer Control - ZONE PRINCIPALE */
.timer-control {
    text-align: center;
    flex: none;
    position: relative;
    overflow: hidden;
}

.timer-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-bottom: 0;
    transform-origin: center center;
    position: absolute;
    top: 35%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.timer-buttons {
    display: contents;
}

.timer-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.timer-digits {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

/* Rangée de flèches (2 par rangée) */
.arrows-row {
    display: flex;
    gap: 24px;
}

/* Flèche individuelle */
.digit-arrow {
    width: 44px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 16px;
    opacity: 0.5;
    transition: var(--transition);
    border-radius: 4px;
}

.digit-arrow:hover {
    opacity: 1;
    color: var(--accent);
    background: rgba(76, 175, 80, 0.1);
    transform: scale(1.1);
}

.digit-arrow:active {
    transform: scale(0.95);
}

/* Box unique par unité - Plus grosse */
.unit-box {
    width: 120px;
    height: 90px;
    background: linear-gradient(180deg, #1a1a2e 0%, #0f0f1a 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid transparent;
    transition: var(--transition);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

.unit-box:hover,
.unit-box:focus-within {
    border-color: var(--accent);
}

.unit-input {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    font-family: var(--font-timer);
    font-size: 56px;
    font-weight: 900;
    color: var(--text-primary);
    text-align: center;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    outline: none;
    padding: 0;
}

.unit-input:focus {
    color: var(--accent);
}

.unit-input::selection {
    background: var(--accent);
    color: white;
}

.timer-separator {
    font-family: var(--font-timer);
    font-size: 56px;
    font-weight: 900;
    color: var(--text-secondary);
    margin: 0 4px;
    align-self: center;
    padding-bottom: 24px; /* Aligné avec les chiffres, pas les flèches */
}

.timer-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 1px;
}

/* Boutons Timer - Layout */
.timer-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 140px;
     transform: scale(1.5);
}

/* Bouton Restart - Position absolue en bas à gauche */
.btn-restart {
    position: absolute;
    left: 20px;
    bottom: 20px;
    padding: 14px 20px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    transform-origin: bottom left;
}

.btn-restart:hover {
    background: var(--border);
    color: var(--text-primary);
}

/* Bouton Reset - Position absolue en bas à droite */
.btn-reset {
    position: absolute;
    right: 20px;
    bottom: 20px;
    padding: 14px 20px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    transform-origin: bottom right;
}

.btn-reset:hover {
    background: var(--border);
    color: var(--text-primary);
}

/* Bouton Play/Pause Toggle - Style moderne rectangle large */
.btn-playpause {
    width: 220px;
    height: 80px;
    border-radius: 16px;
    font-size: 36px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #5cbf60 0%, #3d9940 100%);
    color: white;
    border: none;
    box-shadow: 
        0 6px 0 #2d7a30,
        0 10px 25px rgba(76, 175, 80, 0.4);
    transition: all 0.1s ease;
    position: absolute !important;
    transform-origin: center center;
}

.btn-playpause:hover {
    box-shadow: 
        0 8px 0 #2d7a30,
        0 12px 30px rgba(76, 175, 80, 0.5);
}

.btn-playpause:active {
    box-shadow: 
        0 2px 0 #2d7a30,
        0 4px 10px rgba(76, 175, 80, 0.3);
}

.btn-playpause.playing {
    background: linear-gradient(180deg, #ffb74d 0%, #f57c00 100%);
    box-shadow: 
        0 6px 0 #c45c00,
        0 8px 20px rgba(255, 152, 0, 0.4);
}

.btn-playpause.playing:hover {
    box-shadow: 
        0 8px 0 #c45c00,
        0 12px 30px rgba(255, 152, 0, 0.5);
}

.btn-playpause.playing:active {
    box-shadow: 
        0 2px 0 #c45c00,
        0 4px 10px rgba(255, 152, 0, 0.3);
}

.btn-playpause .play-icon,
.btn-playpause .pause-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-playpause .pause-icon {
    display: none;
}

.btn-playpause.playing .play-icon {
    display: none;
}

.btn-playpause.playing .pause-icon {
    display: flex;
    gap: 6px;
}

.btn-playpause .pause-icon span {
    display: block;
    width: 10px;
    height: 32px;
    background: white;
    border-radius: 2px;
}

.btn-timer {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Preview Master - 16:9 Compact */
.preview-master {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    padding: 12px;
    overflow: hidden;
}

.preview-header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 8px;
}

.preview-title {
    display: none;
}

.btn-fullscreen {
    background: var(--accent);
    color: white;
    padding: 0;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    flex-shrink: 0;
    position: absolute !important;
    top: 50%;
    left: 75%;
    transform: translate(-50%, -50%);
    transform-origin: center center;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    width: 70px;
    height: 50px;
    box-sizing: border-box;
}

.btn-fullscreen:hover {
    background: var(--accent-hover);
}

.btn-fullscreen.hidden {
    display: none;
}

/* Preview Master - ZONE PRINCIPALE */
.preview-master {
    text-align: center;
    flex: none;
    position: relative;
    overflow: hidden;
}

.preview-layout {
    position: relative;
    width: 100%;
    height: 100%;
}

.preview-container {
    position: absolute;
    top: 50%;
    left: 40%;
    transform: translate(-50%, -50%);
    aspect-ratio: 16 / 9;
    width: 50%;
    max-width: 800px;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px solid var(--border);
    transform-origin: center center;
    pointer-events: auto;
}

.preview-master.output-open .preview-container {
    /* Garde le ratio 16:9 et s'adapte à la hauteur */
}

.preview-master.output-open .btn-fullscreen {
    background: #e74c3c;
}

.preview-master.output-open .btn-fullscreen:hover {
    background: #c0392b;
}

.btn-fullscreen .btn-icon {
    font-size: 16px;
    line-height: 1;
    margin: 0;
    padding: 0;
    display: block;
}

.btn-fullscreen .btn-text {
    font-size: 10px;
    line-height: 1;
    margin: 0;
    padding: 0;
    display: block;
}

.preview-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-timer);
    font-size: 24px;
    font-weight: 900;
    color: white;
}

/* Text Control - Responsive en hauteur */
.text-control {
    flex: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.text-input-row {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: 100%;
}

.text-main-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
    min-height: 0;
    flex-shrink: 1;
}

.text-input {
    padding: 16px 20px;
    font-size: 24px;
    min-height: 40px;
    resize: none;
    font-family: var(--font-main);
    line-height: 1.4;
    height: 100%;
    flex: 1;
}

.text-mode-buttons-vertical {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-shrink: 0;
}

/* Bouton Toggle Afficher/Masquer */
.btn-toggle-text {
    width: 100%;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 18px;
    font-weight: 700;
    background: var(--success);
    min-height: 30px;
    color: white;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-toggle-text:hover {
    transform: scale(1.01);
}

.btn-toggle-text.showing {
    background: var(--danger);
}

.text-mode-btn {
    width: 50px;
    height: 50px;
    padding: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 20px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    cursor: pointer;
}

.text-mode-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
    transform: scale(1.05);
}

.text-mode-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* Supprimer les anciens styles non utilisés */
.text-buttons-row {
    display: flex;
    gap: 8px;
}

.btn-toggle-text {
    flex: 1;
    padding: 16px;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 700;
    background: var(--success);
    color: white;
    transition: all 0.2s ease;
}

.btn-toggle-text:hover {
    transform: scale(1.01);
}

.btn-toggle-text.showing {
    background: var(--danger);
}

.btn-text-settings {
    width: 54px;
    height: 54px;
    border-radius: var(--radius);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.btn-text-settings:hover {
    border-color: var(--accent);
    background: var(--border);
}

/* Popup overlay */
.popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.popup-overlay.active {
    display: flex;
}

.popup-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border);
    min-width: 320px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.popup-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.popup-close {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.popup-close:hover {
    background: var(--border);
    color: var(--text-primary);
}

.popup-body {
    padding: 20px;
}

.text-mode-options {
    display: flex;
    gap: 10px;
}

.text-mode-options .text-mode-btn {
    flex: 1;
    padding: 16px 12px;
}

.btn-text {
    padding: 16px 28px;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 700;
    min-width: 120px;
}

.btn-show {
    background: var(--success);
    color: white;
}

.btn-show:hover {
    background: #43a047;
    transform: scale(1.02);
}

.btn-hide {
    background: var(--danger);
    color: white;
}

.btn-hide:hover {
    background: #d32f2f;
    transform: scale(1.02);
}

/* ============================================
   RIGHT PANEL - PRESETS
============================================ */
.panel-right {
    width: 220px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    overflow: hidden;
    position: relative;
    z-index: 500;
}

.panel-right.collapsed {
    width: 0;
    border-left: none;
}

.panel-right.collapsed .preset-section,
.panel-right.collapsed .panel-right-header {
    opacity: 0;
    pointer-events: none;
}

.panel-right-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    min-height: 60px;
}

.panel-right-header .panel-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-right-header .btn-collapse-right {
    width: 28px;
    height: 28px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: var(--transition);
}

.panel-right-header .btn-collapse-right:hover {
    background: var(--border);
    color: var(--text-primary);
}

.preset-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--border);
    min-height: 0;
}

.preset-section:last-child {
    border-bottom: none;
}

.preset-header {
    padding: 10px 16px;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-edit-preset {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-edit-preset:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-edit-preset.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.preset-list {
    flex: 1;
    padding: 8px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
}

.preset-item {
    background: var(--bg-card);
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preset-item:hover {
    border-color: var(--accent);
    background: var(--bg-tertiary);
}

.preset-item .btn-delete-preset {
    display: none;
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    background: var(--danger);
    border: none;
    border-radius: 4px;
    color: white;
    font-size: 12px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.preset-list.edit-mode .preset-item {
    cursor: default;
    padding-right: 35px;
}

.preset-list.edit-mode .preset-item:hover {
    border-color: var(--danger);
}

.preset-list.edit-mode .preset-item .btn-delete-preset {
    display: flex;
}

.btn-add-preset {
    display: none;
    background: transparent;
    border: 2px dashed var(--border);
    color: var(--text-secondary);
    padding: 10px;
    border-radius: var(--radius);
    font-size: 12px;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 8px;
    margin-top: 0;
    flex-shrink: 0;
}

.preset-section.edit-mode .btn-add-preset {
    display: flex;
}

.btn-add-preset:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.preset-input-container {
    display: flex;
    gap: 6px;
    margin: 8px;
    margin-top: 0;
    flex-shrink: 0;
}

.preset-input {
    flex: 1;
    padding: 8px 10px;
    background: var(--bg-dark);
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
}

.preset-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 184, 212, 0.3);
}

.preset-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.btn-confirm-preset {
    padding: 8px 12px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    color: var(--bg-dark);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.btn-confirm-preset:hover {
    background: var(--accent-hover);
}

.btn-cancel-preset {
    padding: 8px 10px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
}

.btn-cancel-preset:hover {
    border-color: var(--danger);
    color: var(--danger);
}

/* ============================================
   SCROLLBAR
============================================ */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ============================================
   RESIZE HANDLES - Mode modification interface
============================================ */
.resize-handle {
    height: 12px;
    background: var(--accent);
    cursor: ns-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    transition: background 0.2s ease;
    flex-shrink: 0;
    position: relative;
    z-index: 1000;
}

.resize-handle:hover {
    background: var(--accent-hover);
}

.resize-handle.dragging {
    background: var(--success);
}

.resize-icon {
    color: white;
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 2px;
}

/* Mode édition actif */
.panel-center.edit-mode {
    border: 2px dashed var(--accent);
}

.panel-center.edit-mode .control-section {
    border: 1px dashed var(--border);
    position: relative;
}

/* Overlay pour bloquer les interactions pendant le resize */
.resize-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    cursor: ns-resize;
}
