/* Modern Digital Signage Admin UI */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #3b82f6;
    --secondary-color: #64748b;
    --accent-color: #06b6d4;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-light: #94a3b8;
    --background-primary: #ffffff;
    --background-secondary: #f8fafc;
    --background-tertiary: #f1f5f9;
    --background-app: #f8fafc;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--background-app);
    min-height: 100vh;
    font-weight: 400;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1.5rem 2rem;
    background: var(--background-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.header h1 {
    color: var(--text-primary);
    font-size: 1.875rem;
    font-weight: 700;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* Modern Buttons */
.btn {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    transition: all 0.15s ease;
    position: relative;
    min-width: 44px;
    min-height: 44px;
    text-align: center;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--background-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

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

.btn-success {
    background: var(--success-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-success:hover {
    background: #059669;
    box-shadow: var(--shadow-md);
}

.btn-warning {
    background: var(--warning-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-warning:hover {
    background: #d97706;
}

.btn-danger {
    background: var(--error-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-danger:hover {
    background: #dc2626;
    box-shadow: var(--shadow-md);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Button Icons */
.btn .material-icons {
    font-size: 1.125rem;
    margin-right: 0.375rem;
    vertical-align: middle;
}

.btn.icon-only {
    padding: 0.625rem;
    min-width: auto;
}

.btn.icon-only .material-icons {
    margin-right: 0;
}

/* Modern Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-family: inherit;
    transition: all 0.15s ease;
    background: var(--background-primary);
    color: var(--text-primary);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-light);
}

/* Better contrast for select options */
.form-group select option {
    background: var(--background-primary);
    color: var(--text-primary);
}

/* Ensure good visibility for disabled inputs */
.form-group input:disabled,
.form-group textarea:disabled,
.form-group select:disabled {
    background: var(--background-secondary);
    color: var(--text-light);
    border-color: var(--border-color);
    cursor: not-allowed;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group input[type="range"] {
    padding: 0;
    height: 6px;
    border-radius: 3px;
    background: var(--background-tertiary);
    -webkit-appearance: none;
    appearance: none;
}

.form-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
}

.form-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.radio-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: normal;
    cursor: pointer;
    padding: 0.5rem 0.875rem;
    border-radius: var(--radius-md);
    transition: all 0.15s ease;
    border: 1px solid var(--border-color);
    background: var(--background-primary);
    font-size: 0.875rem;
}

.radio-group label:hover {
    background: var(--background-secondary);
    border-color: var(--secondary-color);
}

.radio-group input[type="radio"]:checked + label {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.help-text {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.5rem;
    line-height: 1.5;
}

/* Modern Login Page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--background-app);
    padding: 1rem;
}

.login-form {
    background: var(--background-primary);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    border: 1px solid var(--border-color);
}

.login-form h1 {
    text-align: center;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.875rem;
}

.login-form p {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.error-message {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    margin-top: 1rem;
    text-align: center;
    border: 1px solid rgba(239, 68, 68, 0.2);
    font-size: 0.875rem;
}

.form-status {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    margin: 0 0 1rem;
    border: 1px solid transparent;
    font-size: 0.875rem;
}

.form-status.error {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
    border-color: rgba(239, 68, 68, 0.2);
}

.form-status.success {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
    border-color: rgba(16, 185, 129, 0.2);
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
}

.modal-content {
    width: min(100%, 480px);
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    background: var(--background-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: 1.5rem;
}

.modal-content h3 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 700;
}

.modal-help-text {
    margin-bottom: 1rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Modern Display Cards */
.displays-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.25rem;
    margin-top: 2rem;
}

.display-card {
    background: var(--background-primary);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
    position: relative;
}

.display-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.display-card h3 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 1.125rem;
    font-weight: 600;
}

.display-card p {
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    line-height: 1.5;
    font-size: 0.875rem;
}

.display-date {
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 500;
}

.display-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.display-actions .btn {
    flex: 1;
    min-width: 100px;
    justify-content: center;
    text-align: center;
    white-space: nowrap;
}

.display-actions .btn .material-icons {
    margin-right: 0.25rem;
    font-size: 1rem;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-secondary);
    background: var(--background-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 2px dashed var(--border-color);
}

.empty-state h3 {
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.empty-state p {
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

/* ─── Config Page: Figma-style Two-Panel Layout ────────────── */

.config-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background: var(--background-app);
}

/* Sticky Header */
.config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
    padding: 0 1.25rem;
    background: var(--background-primary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
    z-index: 10;
}

.config-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.config-header-title {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.config-header-label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
    font-weight: 500;
    line-height: 1;
}

.config-title-input {
    background: none;
    border: 1px solid transparent;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    padding: 0.125rem 0.375rem;
    margin: 0;
    border-radius: var(--radius-sm);
    font-family: inherit;
    line-height: 1.4;
}

.config-title-input:hover {
    border-color: var(--border-color);
}

.config-title-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.config-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    min-height: 36px;
    font-size: 0.8125rem;
}

.btn-sm .material-icons {
    font-size: 1rem;
    margin-right: 0.25rem;
}

/* Body: Center + Panel */
.config-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 0;
}

.config-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem 1.25rem;
    overflow: hidden;
    min-width: 0;
}

.config-panel {
    width: min(420px, 36vw);
    min-width: 360px;
    flex-shrink: 0;
    background: var(--background-primary);
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) var(--background-tertiary);
}

.config-panel::-webkit-scrollbar {
    width: 6px;
}

.config-panel::-webkit-scrollbar-track {
    background: var(--background-tertiary);
}

.config-panel::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

@media (max-width: 1100px) {
    .config-body {
        flex-direction: column;
        overflow: auto;
    }

    .config-center {
        min-height: 44vh;
    }

    .config-panel {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        max-height: 48vh;
        border-left: none;
        border-top: 1px solid var(--border-color);
    }
}

/* Grid Toolbar */
.grid-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 1rem;
    background: var(--background-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 0.75rem;
    flex-shrink: 0;
    gap: 0.75rem;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toolbar-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.toolbar-select {
    padding: 0.3125rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-family: inherit;
    background: var(--background-primary);
    color: var(--text-primary);
    cursor: pointer;
}

.toolbar-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.toolbar-x {
    color: var(--text-light);
    font-size: 0.875rem;
}

.toolbar-hint {
    font-size: 0.75rem;
    color: var(--text-light);
}

.toolbar-hint.is-success {
    color: var(--success-color);
}

.toolbar-hint.is-error {
    color: var(--error-color);
}

/* Grid Canvas */
.grid-canvas {
    flex: 1;
    display: grid;
    gap: 12px;
    padding: 1rem;
    background: var(--background-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    min-height: 300px;
}

.grid-zone {
    background: var(--background-primary);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    overflow: hidden;
    min-height: 80px;
    user-select: none;
}

.grid-zone:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.grid-zone.configured {
    border-style: solid;
    border-color: var(--success-color);
    background: rgba(16, 185, 129, 0.04);
    cursor: grab;
}

.grid-zone.selected {
    border: 3px solid var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    background: rgba(37, 99, 235, 0.04);
}

.grid-zone.dragging {
    opacity: 0.9;
    z-index: 5;
    box-shadow: 0 12px 32px rgba(37, 99, 235, 0.2);
}

.grid-zone.drag-invalid {
    border-color: var(--error-color) !important;
    background: rgba(239, 68, 68, 0.08) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12) !important;
}

.grid-zone.selected .zone-label {
    color: var(--primary-color);
    font-weight: 600;
}

.grid-zone.merge-mode {
    cursor: crosshair;
}

.grid-zone.merge-mode:hover {
    border-color: var(--accent-color);
    background: rgba(6, 182, 212, 0.06);
}

.grid-zone.merge-selected {
    border-color: var(--primary-color) !important;
    border-style: solid !important;
    background: rgba(37, 99, 235, 0.1) !important;
    box-shadow: inset 0 0 0 2px var(--primary-color);
}

.grid-zone.merge-selected.merge-valid {
    border-color: var(--success-color) !important;
    background: rgba(16, 185, 129, 0.08) !important;
    box-shadow: inset 0 0 0 2px var(--success-color);
}

.grid-zone.merge-selected.merge-invalid {
    border-color: var(--error-color) !important;
    background: rgba(239, 68, 68, 0.08) !important;
    box-shadow: inset 0 0 0 2px var(--error-color);
}

.zone-label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    text-align: center;
    position: relative;
    z-index: 2;
}

.zone-span-badge {
    font-size: 0.6875rem;
    opacity: 0.6;
}

.zone-type-badge {
    position: absolute;
    top: 0.375rem;
    left: 0.375rem;
    background: var(--primary-color);
    color: white;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.625rem;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.03em;
    z-index: 2;
}

.zone-actions {
    position: absolute;
    top: 0.375rem;
    right: 0.375rem;
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 3;
}

.grid-zone:hover .zone-actions {
    opacity: 1;
}

.grid-zone.selected .zone-actions {
    opacity: 1;
}

.zone-action-btn {
    background: var(--background-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.15s ease;
    box-shadow: var(--shadow-sm);
}

.zone-action-btn:hover {
    background: var(--error-color);
    color: white;
    border-color: var(--error-color);
}

.zone-action-btn .material-icons {
    font-size: 0.875rem;
}

.zone-resize-handle {
    position: absolute;
    right: 0.45rem;
    bottom: 0.45rem;
    width: 16px;
    height: 16px;
    border-radius: 4px;
    background: var(--primary-color);
    box-shadow: var(--shadow-sm);
    cursor: nwse-resize;
    z-index: 3;
}

.zone-resize-handle::before {
    content: '';
    position: absolute;
    inset: 4px;
    border-right: 2px solid rgba(255, 255, 255, 0.9);
    border-bottom: 2px solid rgba(255, 255, 255, 0.9);
}

body.zones-interacting .grid-zone {
    transition: none;
}

body.zones-interacting .grid-zone.configured {
    cursor: grabbing;
}

/* Panel Header */
.panel-header {
    padding: 1rem 1.25rem 0;
    border-bottom: 1px solid var(--border-color);
}

.panel-header h3 {
    margin: 0 0 0.25rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.panel-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-subtitle {
    font-size: 0.75rem;
    color: var(--text-light);
    margin: 0 0 0.75rem;
}

/* Panel Tabs */
.panel-tabs {
    display: flex;
    gap: 0;
    margin-top: 0.5rem;
}

.panel-tab {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
}

.panel-tab:hover {
    color: var(--text-primary);
    background: var(--background-secondary);
}

.panel-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

/* Tab Panes */
.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* Panel Body */
.panel-body {
    padding: 1rem 1.25rem;
}

/* Accordion */
.accordion-section {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.accordion-header {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.625rem 0.75rem;
    background: var(--background-secondary);
    border: none;
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: inherit;
    color: var(--text-primary);
    gap: 0.5rem;
    transition: background 0.15s ease;
}

.accordion-header:hover {
    background: var(--background-tertiary);
}

.accordion-header .material-icons:first-child {
    font-size: 1rem;
    color: var(--text-secondary);
}

.accordion-header span {
    flex: 1;
    text-align: left;
}

.accordion-chevron {
    font-size: 1.125rem !important;
    color: var(--text-light) !important;
    transition: transform 0.2s ease;
}

.accordion-section.open .accordion-chevron {
    transform: rotate(180deg);
}

.accordion-content {
    display: none;
    padding: 0.75rem;
}

.accordion-section.open .accordion-content {
    display: block;
}

/* Zone Type Picker Grid */
.zone-type-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.zone-type-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.625rem 0.5rem;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.15s ease;
    background: var(--background-primary);
}

.zone-type-card:hover {
    border-color: var(--primary-color);
    border-style: solid;
    background: var(--background-secondary);
}

.zone-type-card.active {
    border-color: var(--primary-color);
    border-style: solid;
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary-color);
}

.zone-type-card .material-icons {
    font-size: 1.25rem;
    color: var(--text-secondary);
}

.zone-type-card.active .material-icons {
    color: var(--primary-color);
}

.zone-type-card span {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Option Cards (background type picker) */
.option-cards {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.option-card {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.15s ease;
    background: var(--background-primary);
    text-align: center;
    white-space: nowrap;
}

.option-card input[type="radio"] {
    display: none;
}

.option-card:hover {
    border-color: var(--primary-color);
}

.option-card.active {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary-color);
    font-weight: 600;
}

/* Form Fields (panel-specific) */
.form-field {
    margin-bottom: 1rem;
}

.form-field:last-child {
    margin-bottom: 0;
}

.form-field label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-field input,
.form-field textarea,
.form-field select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-family: inherit;
    background: var(--background-primary);
    color: var(--text-primary);
    transition: border-color 0.15s ease;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-field input[type="range"] {
    padding: 0;
    height: 6px;
    border-radius: 3px;
    background: var(--background-tertiary);
    -webkit-appearance: none;
    appearance: none;
    border: none;
    box-shadow: none;
}

.form-field input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 18px;
    width: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.form-field input[type="color"] {
    padding: 0.25rem;
    height: 40px;
    cursor: pointer;
}

.weather-color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
}

.weather-color-field {
    min-width: 0;
}

.weather-color-field span {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.free-text-editor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.free-text-editor-grid .form-field {
    margin-bottom: 0;
}

.zone-template-field {
    margin-top: 1rem;
}

.zone-template-toolbar {
    display: grid;
    gap: 0.75rem;
}

.zone-template-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 0.5rem;
    align-items: center;
}

.zone-template-row--save {
    grid-template-columns: minmax(0, 1fr) auto;
}

.zone-template-row select,
.zone-template-row input {
    min-width: 0;
}

.zone-template-help {
    margin-top: 0.5rem;
}

.zone-template-help.is-error {
    color: var(--danger-color);
}

@media (max-width: 640px) {
    .zone-template-row,
    .zone-template-row--save {
        grid-template-columns: 1fr;
    }
}

.form-field input[type="checkbox"] {
    width: auto;
    margin-right: 0.5rem;
}

.gradient-preview {
    height: 36px;
    border-radius: var(--radius-sm);
    margin-top: 0.5rem;
    border: 1px solid var(--border-color);
}

.asset-preview {
    margin-top: 0.625rem;
    min-height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    background: var(--background-secondary);
    overflow: hidden;
}

.asset-preview.is-empty {
    color: var(--text-light);
    text-align: center;
}

.asset-preview img {
    display: block;
    max-width: 100%;
    max-height: 220px;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.asset-preview-copy {
    font-size: 0.8125rem;
    line-height: 1.5;
}

.slideshow-asset-preview {
    width: 100%;
}

.slideshow-asset-summary {
    margin-bottom: 0.75rem;
    font-size: 0.8125rem;
    color: var(--text-light);
}

.slideshow-asset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
    gap: 0.75rem;
}

.slideshow-asset-item {
    margin: 0;
    min-width: 0;
}

.slideshow-asset-item img {
    width: 100%;
    height: 84px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--surface-color, #fff);
}

.slideshow-asset-item figcaption {
    margin-top: 0.375rem;
    font-size: 0.6875rem;
    line-height: 1.4;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.asset-library-field {
    margin-top: 0.25rem;
}

.asset-library-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 0.75rem 0;
}

.asset-library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
    gap: 0.75rem;
}

.asset-library-card {
    width: 100%;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--background-primary);
    overflow: hidden;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
    text-align: left;
}

.asset-library-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
    border-color: var(--primary-color);
}

.asset-library-card.is-active {
    border-color: var(--success-color);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

.asset-library-card.is-selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.asset-library-card img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: var(--background-secondary);
}

.asset-library-meta {
    display: grid;
    gap: 0.125rem;
    padding: 0.625rem 0.75rem 0.75rem;
}

.asset-library-meta strong,
.asset-library-meta span {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.asset-library-meta strong {
    font-size: 0.8125rem;
    color: var(--text-primary);
}

.asset-library-meta span {
    font-size: 0.75rem;
    color: var(--text-light);
}

.asset-library-action-copy {
    color: var(--primary-color) !important;
    font-weight: 600;
}

.asset-library-empty {
    padding: 0.875rem 1rem;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    background: var(--background-secondary);
    color: var(--text-light);
    font-size: 0.8125rem;
    line-height: 1.5;
}

/* Schedule Entries */
.schedule-entry {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--background-secondary);
    min-width: 0;
}

.schedule-entry-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5rem;
    align-items: start;
    margin-bottom: 0.5rem;
    min-width: 0;
}

.schedule-entry-main {
    display: grid;
    gap: 0.5rem;
    min-width: 0;
}

.schedule-entry-header input {
    padding: 0.375rem;
    font-size: 0.8125rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    background: var(--background-primary);
    color: var(--text-primary);
    width: 100%;
    min-width: 0;
}

.schedule-entry-header .schedule-label {
    display: block;
}

.schedule-time-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
    gap: 0.5rem;
    min-width: 0;
}

.schedule-time-field {
    display: grid;
    gap: 0.25rem;
    min-width: 0;
}

.schedule-time-field span {
    color: var(--text-secondary);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.schedule-time-field input {
    min-width: 0;
    max-width: 100%;
}

.schedule-remove-btn {
    min-width: 36px;
    padding: 0.375rem;
    align-self: start;
}

.schedule-remove-btn .material-icons {
    margin-right: 0;
}

.schedule-days {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.schedule-day-label {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 0.6875rem;
    font-weight: 500;
    cursor: pointer;
}

.schedule-content {
    width: 100%;
    padding: 0.375rem;
    font-size: 0.8125rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    background: var(--background-primary);
    color: var(--text-primary);
    resize: vertical;
}

/* Preview Slide-out */
.preview-slideout {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 50%;
    height: 50%;
    background: var(--background-primary);
    border-top: 1px solid var(--border-color);
    border-left: 1px solid var(--border-color);
    box-shadow: var(--shadow-xl);
    z-index: 100;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-lg) 0 0 0;
}

.preview-slideout.visible {
    transform: translateY(0);
}

.preview-slideout-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8125rem;
    font-weight: 600;
    flex-shrink: 0;
}

.preview-slideout-header > div {
    display: flex;
    gap: 0.25rem;
}

.preview-slideout-body {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #0a0a0f;
}

.preview-slideout-body iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    height: 200%;
    transform: scale(0.5);
    transform-origin: top left;
    border: none;
}

/* Save button pulse animation */
.save-pulse {
    animation: savePulse 1.5s ease infinite;
}

@keyframes savePulse {
    0%, 100% { box-shadow: var(--shadow-sm); }
    50% { box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.3); }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-lg);
    font-size: 0.8125rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    opacity: 0;
    transform: translateY(1rem);
    transition: all 0.3s ease;
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.toast .material-icons {
    font-size: 1.125rem;
}

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

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

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

/* Legacy compat — keep config-section for non-config pages if any */
.config-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.config-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.config-section h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Additional Modern UI Enhancements */

/* Loading States */
.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Modern Tables */
.table-container {
    background: var(--background-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table th {
    background: var(--background-secondary);
    padding: 0.875rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    transition: background-color 0.15s ease;
}

.table tr:hover td {
    background: var(--background-secondary);
}

.table tr:last-child td {
    border-bottom: none;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.active {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-badge.inactive {
    background: rgba(107, 114, 128, 0.1);
    color: var(--text-light);
    border: 1px solid rgba(107, 114, 128, 0.2);
}

.status-badge.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Improved Typography */
.text-large {
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.4;
}

.text-small {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.text-xs {
    font-size: 0.75rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

/* Enhanced Tooltips */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
    box-shadow: var(--shadow-md);
}

.tooltip::after {
    content: '';
    position: absolute;
    bottom: 115%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--text-primary);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.tooltip:hover::before,
.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}


/* Focus Management */
*:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Improved Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
    border: 2px solid var(--background-tertiary);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* Display Status Indicators */
.display-status {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.display-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 4px;
    display: inline-block;
}

.status-online {
    color: var(--success-color);
    background: rgba(16, 185, 129, 0.1);
}

.status-online::before {
    background: var(--success-color);
    box-shadow: 0 0 4px var(--success-color);
}

.status-offline {
    color: var(--text-light);
    background: rgba(148, 163, 184, 0.1);
}

.status-offline::before {
    background: var(--text-light);
}

/* (Merge mode and zone split styles moved to config-page section above) */

/* Print Styles */
@media print {
    .btn, .header-actions, .modal {
        display: none !important;
    }
    
    .container {
        max-width: none;
        padding: 0;
    }
    
    .display-card, .config-sidebar, .config-main {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}


/* Responsive Button Layout */
@media (max-width: 480px) {
    .display-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .display-actions .btn {
        flex: none;
        width: 100%;
        min-width: auto;
    }
}

@media (max-width: 768px) {
    .config-header {
        flex-wrap: wrap;
        align-items: flex-start;
        height: auto;
        padding: 0.875rem 1rem;
        gap: 0.75rem;
    }

    .config-header-left,
    .config-header-right {
        width: 100%;
    }

    .config-header-right,
    .grid-toolbar,
    .toolbar-group {
        flex-wrap: wrap;
    }

    .config-center {
        padding: 0.75rem;
    }

    .config-panel {
        max-height: 52vh;
    }

    .panel-tabs {
        overflow-x: auto;
    }

    .panel-tab {
        flex: 0 0 auto;
        min-width: 96px;
    }

    .panel-body {
        padding: 0.875rem 1rem;
    }

    .schedule-entry {
        padding: 0.625rem;
    }

    .schedule-entry-header {
        grid-template-columns: 1fr;
    }

    .schedule-time-grid {
        grid-template-columns: 1fr;
    }

    .schedule-remove-btn {
        width: 100%;
    }

    .display-actions .btn {
        font-size: 0.8rem;
        padding: 0.6rem 1rem;
    }
    
    .display-actions .btn .material-icons {
        font-size: 0.9rem;
    }
}
