/* ================= ROOT VARIABLES ================= */
:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a2235;
    --bg-card-hover: #1f2a40;
    --bg-input: #0f1629;
    --border-color: #2a3a5c;
    --border-hover: #3a5090;
    --text-primary: #e8edf5;
    --text-secondary: #8892a8;
    --text-muted: #5a6480;
    --accent-cyan: #00d4ff;
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-green: #10b981;
    --accent-orange: #f59e0b;
    --accent-red: #ef4444;
    --lcd-bg: #0d1b0e;
    --lcd-text: #33ff33;
    --lcd-glow: rgba(51, 255, 51, 0.15);
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 30px rgba(0, 212, 255, 0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

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

/* ================= APP LAYOUT ================= */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ================= SIDEBAR ================= */
.sidebar {
    width: 240px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 28px;
    color: var(--accent-cyan);
    text-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.logo-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.1), rgba(59, 130, 246, 0.05));
    color: var(--accent-cyan);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: var(--accent-cyan);
    border-radius: 0 3px 3px 0;
    box-shadow: 0 0 12px rgba(0, 212, 255, 0.4);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.mobile-conn {
    display: none; /* only visible on phone */
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: var(--transition);
}

.status-dot.online {
    background: var(--accent-green);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
    animation: pulse-dot 2s infinite;
}

.status-dot.offline {
    background: var(--accent-red);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.3);
}

.status-text {
    color: var(--text-secondary);
}

/* ================= MAIN CONTENT ================= */
.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 32px 40px;
    min-height: 100vh;
}

.section {
    display: none;
    animation: fadeIn 0.4s ease;
}

.section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-header {
    margin-bottom: 32px;
}

.section-header h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.section-desc {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 4px;
}

/* ================= CARDS ================= */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    transition: var(--transition);
}

.card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-glow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding-top: 4px;
}

.card-description {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 16px;
    line-height: 1.5;
}

/* ================= BADGE ================= */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(0, 212, 255, 0.1);
    color: var(--accent-cyan);
    border: 1px solid rgba(0, 212, 255, 0.2);
}

.badge.info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-blue);
    border-color: rgba(59, 130, 246, 0.2);
}

/* ================= DASHBOARD GRID ================= */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.dashboard-grid .card:first-child {
    grid-column: 1 / -1;
}

.dashboard-grid .php-card {
    grid-column: 1 / -1;
}

/* ================= LCD PREVIEW ================= */
.lcd-card {}

.lcd-preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
}

.lcd-screen {
    background: var(--lcd-bg);
    border-radius: var(--radius-md);
    padding: 20px 28px;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 4 / 1.2;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
    box-shadow:
        inset 0 0 60px rgba(0, 0, 0, 0.8),
        0 0 20px var(--lcd-glow),
        0 0 60px var(--lcd-glow);
    border: 2px solid #1a3a1a;
}

.lcd-line {
    font-family: 'JetBrains Mono', monospace;
    font-size: 18px;
    font-weight: 600;
    color: var(--lcd-text);
    text-shadow: 0 0 10px rgba(51, 255, 51, 0.5);
    letter-spacing: 3px;
    text-align: center;
    line-height: 1.4;
    min-height: 1.4em;
    white-space: pre;
}

.lcd-scanlines {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.15) 2px,
        rgba(0, 0, 0, 0.15) 4px
    );
    pointer-events: none;
}

.lcd-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Color picker row below LCD preview */
.color-picker-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.color-picker-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    margin-right: 4px;
}

.color-swatch {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 700;
    transition: var(--transition);
}

.color-swatch:hover {
    transform: scale(1.15);
    box-shadow: 0 0 12px rgba(255,255,255,0.15);
}

.color-swatch.active {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(0,212,255,0.3);
    transform: scale(1.1);
}

.color-swatch-custom {
    width: 30px;
    border-style: dashed;
}

/* Theme preview mini LCD in Layouts section */
.theme-preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.theme-lcd-mini {
    background: var(--lcd-bg);
    border-radius: var(--radius-sm);
    padding: 14px 20px;
    width: 100%;
    max-width: 340px;
    border: 2px solid #1a3a1a;
    box-shadow:
        inset 0 0 20px rgba(0,0,0,0.6),
        0 0 12px var(--lcd-glow);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.theme-lcd-line {
    font-family: 'JetBrains Mono', monospace;
    font-size: 15px;
    font-weight: 600;
    color: var(--lcd-text);
    text-shadow: 0 0 8px rgba(51,255,51,0.4);
    letter-spacing: 2px;
    text-align: center;
    line-height: 1.4;
    white-space: pre;
}

/* ================= INFO GRID ================= */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.info-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.clock-icon { background: rgba(0, 212, 255, 0.1); color: var(--accent-cyan); }
.temp-icon { background: rgba(245, 158, 11, 0.1); color: var(--accent-orange); }
.date-icon { background: rgba(16, 185, 129, 0.1); color: var(--accent-green); }
.msg-icon { background: rgba(139, 92, 246, 0.1); color: var(--accent-purple); }

.info-data {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.info-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.info-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ================= ACTIONS GRID ================= */
.actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.action-btn:hover {
    background: rgba(0, 212, 255, 0.06);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    transform: translateY(-1px);
}

.action-btn.danger:hover {
    background: rgba(239, 68, 68, 0.06);
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.action-btn svg {
    flex-shrink: 0;
}

/* ================= PHP CARD ================= */
.php-card .card-header {
    margin-bottom: 12px;
}

.php-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.php-url {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.php-url a {
    color: var(--accent-cyan);
    text-decoration: none;
    transition: var(--transition);
}

.php-url a:hover {
    color: var(--accent-blue);
    text-decoration: underline;
}

.php-last-msg {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    gap: 8px;
}

.php-last-msg .label {
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ================= TOGGLE SWITCH ================= */
.toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    width: 44px;
    height: 24px;
    background: var(--bg-input);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
    position: relative;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: var(--transition);
}

.toggle input:checked + .toggle-slider {
    background: rgba(0, 212, 255, 0.2);
    border-color: var(--accent-cyan);
}

.toggle input:checked + .toggle-slider::after {
    left: 22px;
    background: var(--accent-cyan);
    box-shadow: 0 0 8px rgba(0, 212, 255, 0.4);
}

/* ================= MESSAGES SECTION ================= */
.messages-grid {
    display: grid;
    gap: 20px;
}

.full-width {
    grid-column: 1 / -1;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.input-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.input-group textarea,
.input-group input[type="text"] {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    resize: vertical;
    width: 100%;
}

.input-group textarea:focus,
.input-group input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

.input-group textarea::placeholder,
.input-group input[type="text"]::placeholder {
    color: var(--text-muted);
}

.input-extra {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.char-count {
    font-size: 12px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.transliteration-hint {
    font-size: 12px;
    color: var(--text-muted);
}

/* ================= MESSAGE PREVIEW ================= */
.message-preview {
    margin-bottom: 16px;
}

.preview-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: block;
}

.preview-lcd {
    background: var(--lcd-bg);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    border: 1px solid #1a3a1a;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.preview-line {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    color: var(--lcd-text);
    text-shadow: 0 0 6px rgba(51, 255, 51, 0.3);
    letter-spacing: 2px;
    min-height: 1.4em;
    white-space: pre;
}

/* ================= BUTTONS ================= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    color: var(--bg-primary);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 212, 255, 0.25);
}

.btn-secondary {
    background: rgba(0, 212, 255, 0.08);
    border: 1px solid rgba(0, 212, 255, 0.2);
    color: var(--accent-cyan);
}

.btn-secondary:hover {
    background: rgba(0, 212, 255, 0.15);
    transform: translateY(-1px);
}

.btn-lg {
    padding: 14px 28px;
    font-size: 15px;
}

/* ================= LAYOUTS GRID ================= */
.layouts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.layout-card {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.layout-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.layout-card.active {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.15), 0 12px 40px rgba(0, 0, 0, 0.3);
}

.layout-card .layout-check {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent-cyan);
    color: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    opacity: 0;
    transform: scale(0);
    transition: var(--transition);
}

.layout-card.active .layout-check {
    opacity: 1;
    transform: scale(1);
}

/* ================= CYCLING INDICATOR ================= */
.cycling-indicator {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 6px;
}

.cyc-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(51, 255, 51, 0.25);
    transition: var(--transition);
}

.cyc-dot.active {
    background: var(--accent-cyan);
    box-shadow: 0 0 6px rgba(0, 212, 255, 0.5);
    width: 8px;
    height: 8px;
}

.cycling-frame-label {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    min-height: 1.2em;
    transition: var(--transition);
}

/* Weather settings styles */
.weather-stat {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 6px;
    font-size: 13px;
}

.weather-stat .label {
    color: var(--text-muted);
    min-width: 40px;
}

.weather-stat .value {
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
}

/* ================= MULTI-PAGE EDITOR ================= */
.editor-page-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
    transition: var(--transition);
}

.editor-page-card:hover {
    border-color: var(--border-hover);
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.page-header h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-cyan);
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-orange);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.page-remove-btn {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-red);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: var(--transition);
}

.page-remove-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    transform: scale(1.1);
}

.page-body .input-group {
    margin-bottom: 10px;
}

.page-body .input-group:last-of-type {
    margin-bottom: 0;
}

.page-duration-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.page-duration-row label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.page-duration-row input[type="number"] {
    width: 60px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px 8px;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    text-align: center;
}

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

.dur-label {
    font-size: 11px;
    color: var(--text-muted);
}

/* ================= DEFAULT BUTTON ================= */
/* Default button (star) on layout cards */
.layout-default-btn {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: var(--transition);
    z-index: 2;
    line-height: 1;
}

.layout-default-btn:hover {
    background: rgba(245, 158, 11, 0.2);
    color: var(--accent-orange);
    transform: scale(1.2);
}

.layout-default-btn.active {
    color: var(--accent-orange);
    background: rgba(245, 158, 11, 0.15);
    text-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

/* Edit/Delete buttons on custom layout cards */
.layout-edit-btn,
.layout-del-btn {
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: var(--transition);
    line-height: 1;
    padding: 0;
}

.layout-edit-btn:hover {
    background: rgba(0, 212, 255, 0.15);
    color: var(--accent-cyan);
}

.layout-del-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
}

/* Block chips for custom layout builder */
.block-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: rgba(0, 212, 255, 0.08);
    border: 1px solid rgba(0, 212, 255, 0.15);
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--accent-cyan);
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.block-chip:hover {
    background: rgba(0, 212, 255, 0.18);
    border-color: var(--accent-cyan);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 212, 255, 0.15);
}

.block-chip:active {
    transform: translateY(0);
}

.block-chip.dragging {
    opacity: 0.5;
    transform: scale(0.95);
    border-style: dashed;
}

/* Drop target highlight for template input containers */
.input-group.drop-target input[type="text"] {
    border-color: var(--accent-orange);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2), 0 0 16px rgba(245, 158, 11, 0.1);
    background: rgba(245, 158, 11, 0.05);
}

.input-group.drop-target label {
    color: var(--accent-orange);
}

.layout-preview {
    background: var(--lcd-bg);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 14px;
    border: 1px solid #1a3a1a;
    min-height: 64px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.4);
}

.layout-line {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--lcd-text);
    text-shadow: 0 0 4px rgba(51, 255, 51, 0.3);
    letter-spacing: 1.5px;
    display: flex;
    gap: 8px;
}

.layout-line.centered {
    justify-content: center;
}

.layout-time { color: var(--lcd-text); }
.layout-time-large { font-size: 14px; letter-spacing: 2px; }
.layout-time-small { font-size: 11px; }
.layout-date { opacity: 0.8; }
.layout-temp { color: #66ff66; opacity: 0.9; }
.layout-msg-scroll {
    overflow: hidden;
    white-space: nowrap;
    animation: scrollText 3s linear infinite;
}
.layout-msg-persist { opacity: 0.9; }

@keyframes scrollText {
    0% { transform: translateX(100%); }
    100% { transform: translateX(-100%); }
}

.layout-info h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.layout-info p {
    font-size: 12px;
    color: var(--text-muted);
}

/* ================= SETTINGS ================= */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.setting-value {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
}

.setting-value.mono {
    font-family: 'JetBrains Mono', monospace;
}

.setting-value.small {
    font-size: 12px;
}

.temp-value {
    color: var(--accent-orange);
    font-family: 'JetBrains Mono', monospace;
    font-size: 15px;
    font-weight: 600;
}

.about-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.about-version {
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.about-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.about-links {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.about-links span {
    padding: 4px 10px;
    background: rgba(0, 212, 255, 0.05);
    border: 1px solid rgba(0, 212, 255, 0.1);
    border-radius: 6px;
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

/* ================= RESTART OVERLAY ================= */
.restart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 14, 23, 0.85);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.restart-overlay-content {
    text-align: center;
    padding: 48px;
    max-width: 420px;
}

.restart-spinner {
    width: 64px;
    height: 64px;
    border: 3px solid rgba(0, 212, 255, 0.15);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 24px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.restart-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.restart-desc {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 20px;
    line-height: 1.5;
}

.restart-timer-ring {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 20px;
}

.restart-timer-ring svg {
    transform: rotate(-90deg);
    width: 120px;
    height: 120px;
}

.restart-timer-ring .bg-circle {
    fill: none;
    stroke: rgba(255, 255, 255, 0.06);
    stroke-width: 4;
}

.restart-timer-ring .progress-circle {
    fill: none;
    stroke: var(--accent-cyan);
    stroke-width: 4;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.3s ease;
    filter: drop-shadow(0 0 6px rgba(0, 212, 255, 0.4));
}

.restart-timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 32px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent-cyan);
}

.restart-status-text {
    font-size: 13px;
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ================= TOAST ================= */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    animation: slideIn 0.3s ease;
    min-width: 280px;
    backdrop-filter: blur(10px);
}

.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error { border-left: 3px solid var(--accent-red); }
.toast.info { border-left: 3px solid var(--accent-cyan); }

.toast-message {
    flex: 1;
    font-size: 13px;
    color: var(--text-primary);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 0 4px;
    transition: var(--transition);
}

.toast-close:hover {
    color: var(--text-primary);
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ================= LOG CONSOLE ================= */
.log-card {
    overflow: visible;
}

.log-console {
    background: #0a0e17;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    max-height: 60vh;
    min-height: 200px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    line-height: 1.7;
    display: flex;
    flex-direction: column;
    gap: 2px;
    resize: vertical;
}

.log-console::-webkit-scrollbar {
    width: 6px;
}

.log-console::-webkit-scrollbar-track {
    background: transparent;
}

.log-console::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.log-line {
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
}

.log-line.muted {
    color: var(--text-muted);
    font-style: italic;
}

.log-line.new-msg {
    color: var(--accent-green);
}

.log-line.manual {
    color: var(--accent-blue);
}

.log-line.error {
    color: var(--accent-red);
}

.log-time {
    color: var(--text-muted);
}

.log-tag-new {
    color: var(--accent-green);
    font-weight: 600;
}

.log-tag-refresh {
    color: var(--accent-blue);
    font-weight: 600;
}

/* ================= RESPONSIVE — TABLET (1024px and below) ================= */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }
}

/* ================= RESPONSIVE — PHONE (768px and below) ================= */
@media (max-width: 768px) {
    /* ===== HIDE SIDEBAR completely, show bottom nav ===== */
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        top: auto;
        width: 100%;
        height: 64px;
        flex-direction: row;
        border-right: none;
        border-top: 1px solid var(--border-color);
        background: var(--bg-secondary);
        z-index: 200;
        padding: 0;
        backdrop-filter: blur(12px);
    }

    .sidebar-header,
    .sidebar-footer {
        display: none;
    }

    /* Mobile connection dot */
    .mobile-conn {
        position: absolute;
        top: -4px;
        right: 6px;
        z-index: 5;
        display: block;
    }

    .mobile-conn .status-dot {
        width: 10px;
        height: 10px;
        border: 2px solid var(--bg-secondary);
    }

    .sidebar-nav {
        flex-direction: row;
        padding: 0;
        gap: 0;
        width: 100%;
        justify-content: space-around;
        align-items: center;
    }

    .nav-item {
        flex-direction: column;
        padding: 6px 4px;
        gap: 2px;
        font-size: 10px;
        border-radius: 8px;
        min-width: 0;
        flex: 1;
        max-width: 80px;
        justify-content: center;
        align-items: center;
    }

    .nav-item svg {
        width: 22px;
        height: 22px;
    }

    .nav-item span {
        display: block !important;
        font-size: 9px;
        line-height: 1.2;
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    .nav-item.active {
        background: rgba(0, 212, 255, 0.12);
    }

    .nav-item.active::before {
        display: none;
    }

    /* ===== MAIN CONTENT full width ===== */
    .main-content {
        margin-left: 0;
        padding: 16px;
        padding-bottom: 80px; /* space for bottom nav */
    }

    /* ===== SECTION HEADERS smaller ===== */
    .section-header {
        margin-bottom: 20px;
    }

    .section-header h1 {
        font-size: 22px;
    }

    .section-desc {
        font-size: 12px;
    }

    /* ===== CARDS compact ===== */
    .card {
        padding: 16px;
        border-radius: var(--radius-md);
    }

    .card-header {
        margin-bottom: 12px;
    }

    .card-header h2 {
        font-size: 14px;
    }

    .badge {
        font-size: 10px;
        padding: 3px 8px;
    }

    /* ===== LCD PREVIEW compact ===== */
    .lcd-screen {
        padding: 14px 16px;
        max-width: 100%;
    }

    .lcd-line {
        font-size: 15px;
        letter-spacing: 2px;
    }

    .lcd-label {
        font-size: 10px;
    }

    /* ===== INFO GRID single column ===== */
    .info-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .info-item {
        padding: 10px;
        gap: 10px;
    }

    .info-icon {
        width: 32px;
        height: 32px;
    }

    .info-icon svg {
        width: 18px;
        height: 18px;
    }

    .info-value {
        font-size: 14px;
    }

    /* ===== ACTIONS single column ===== */
    .actions-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .action-btn {
        padding: 12px 14px;
        font-size: 12px;
        justify-content: center;
    }

    .action-btn svg {
        width: 18px;
        height: 18px;
    }

    /* ===== LAYOUTS ===== */
    .layouts-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 10px;
    }

    .layout-card {
        padding: 14px;
    }

    .layout-card .layout-check {
        width: 20px;
        height: 20px;
        font-size: 11px;
        top: 8px;
        right: 8px;
    }

    .layout-default-btn {
        width: 20px;
        height: 20px;
        font-size: 12px;
        top: 8px;
        left: 8px;
    }

    .layout-preview {
        padding: 8px;
        min-height: 48px;
        margin-bottom: 10px;
    }

    .layout-line {
        font-size: 10px;
        letter-spacing: 1px;
    }

    .layout-time-large {
        font-size: 12px;
    }

    .layout-info h3 {
        font-size: 12px;
    }

    .layout-info p {
        font-size: 10px;
    }

    /* Custom layouts container */
    #customLayoutsContainer {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)) !important;
        gap: 10px !important;
    }

    /* ===== MESSAGES ===== */
    .messages-grid {
        gap: 12px;
    }

    .input-group textarea,
    .input-group input[type="text"] {
        padding: 10px 12px;
        font-size: 13px;
    }

    .btn {
        padding: 10px 18px;
        font-size: 13px;
        justify-content: center;
        width: 100%;
    }

    .btn-lg {
        padding: 12px 20px;
        font-size: 14px;
    }

    .preview-lcd {
        padding: 10px 12px;
    }

    .preview-line {
        font-size: 13px;
        letter-spacing: 1px;
    }

    /* ===== SETTINGS ===== */
    .settings-grid {
        gap: 12px;
    }

    .settings-form {
        gap: 8px;
    }

    .setting-item {
        padding: 8px 0;
        flex-wrap: wrap;
        gap: 6px;
    }

    .setting-label {
        font-size: 12px;
        min-width: 70px;
    }

    .setting-value {
        font-size: 12px;
    }

    .setting-value.mono {
        font-size: 11px;
        word-break: break-all;
    }

    /* ===== PHP ===== */
    .php-info {
        gap: 6px;
    }

    .php-url {
        font-size: 12px;
    }

    .php-url a {
        word-break: break-all;
    }

    .php-last-msg {
        font-size: 12px;
    }

    /* ===== LOG CONSOLE ===== */
    .log-console {
        max-height: 50vh;
        min-height: 200px;
        font-size: 11px;
        padding: 10px 12px;
        resize: vertical;
    }

    /* ===== TOAST higher (above bottom nav) ===== */
    .toast-container {
        bottom: 76px;
        right: 12px;
        left: 12px;
    }

    .toast {
        min-width: 0;
        width: 100%;
        padding: 12px 16px;
    }

    .toast-message {
        font-size: 12px;
    }

    /* ===== COLOR PICKER ===== */
    .color-picker-row {
        gap: 4px;
    }

    .color-swatch {
        width: 24px;
        height: 24px;
        font-size: 9px;
    }

    .theme-lcd-mini {
        padding: 10px 14px;
        max-width: 100%;
    }

    .theme-lcd-line {
        font-size: 13px;
        letter-spacing: 1px;
    }

    /* Custom color inputs */
    #customColorInputs > div:first-child {
        flex-direction: column !important;
        gap: 8px !important;
        align-items: stretch !important;
    }

    #customColorInputs > div:first-child > div {
        flex: 1;
    }

    /* ===== ABOUT ===== */
    .about-version {
        font-size: 16px;
    }

    .about-desc {
        font-size: 12px;
    }

    .about-links span {
        font-size: 10px;
        padding: 3px 8px;
    }

    /* ===== SECTION SUBHEADERS ===== */
    .section-subheader h2 {
        font-size: 18px !important;
    }

    /* ===== BLOCK CHIPS for custom layout builder ===== */
    .block-chip {
        padding: 6px 10px;
        font-size: 11px;
    }
}

/* ================= RESPONSIVE — SMALL PHONE (480px and below) ================= */
@media (max-width: 480px) {
    .main-content {
        padding: 12px;
        padding-bottom: 72px;
    }

    .section-header h1 {
        font-size: 20px;
    }

    .card {
        padding: 12px;
        border-radius: 10px;
    }

    .layouts-grid,
    #customLayoutsContainer {
        grid-template-columns: 1fr !important;
    }

    .lcd-screen {
        padding: 12px 12px;
    }

    .lcd-line {
        font-size: 14px;
        letter-spacing: 1px;
    }

    .actions-grid {
        grid-template-columns: 1fr;
    }

    .nav-item {
        max-width: 64px;
        padding: 4px 2px;
    }

    .nav-item svg {
        width: 20px;
        height: 20px;
    }

    .nav-item span {
        font-size: 8px;
    }

    .sidebar {
        height: 56px;
    }

    .info-grid {
        gap: 6px;
    }

    .setting-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .setting-item > div {
        width: 100%;
    }

    .setting-item input[type="number"] {
        width: 60px !important;
    }

    .temp-value {
        font-size: 14px;
    }
}
