/* --- v10.2 CLEAN & FIXED --- */

/* --- 1. БАЗОВІ СТИЛІ (CSS VARIABLES) --- */
:root {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-color: #e0e0e0;
    --text-label: #dcdcdc;
    --accent-color: #e65100;
    --accent-hover: #ff6d00;
    --success-color: #00c853;
    --error-color: #cf6679;
    --input-bg: #2d2d2d;
    --border-color: #444;
    --radius: 12px;
    --content-width: 400px;
    --warn-color: #ff9800;
}

* { box-sizing: border-box; }

body {
    font-size: 18px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-x: hidden; /* Виправлено: лише горизонтальний скрол ховаємо */
}

/* --- 2. ЗАСТАВКА (SPLASH SCREEN) --- */
/* Z-Index: 9999 (Вище контенту, нижче модалок) */
#splash-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: #000000;
    z-index: 9999;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    transition: opacity 0.8s ease-out, visibility 0.8s;
}
#splash-screen.fade-out { opacity: 0; visibility: hidden; pointer-events: none; }

.splash-content {
    text-align: center;
    display: flex; flex-direction: column; align-items: center;
    animation: pulse 2s infinite;
}

.splash-title { font-size: 1.2em; letter-spacing: 3px; color: #666; margin-bottom: 10px; text-transform: uppercase; }
.splash-logo { font-size: 2.5em; font-weight: bold; color: var(--accent-color); margin: 0; letter-spacing: 1px; text-transform: uppercase; }
.splash-bar {
    width: 200px; height: 2px; background: #333;
    margin: 30px auto 15px auto;
    position: relative; overflow: hidden; border-radius: 2px;
}
.splash-progress {
    position: absolute; top: 0; left: 0; height: 100%; width: 50%;
    background: var(--accent-color);
    animation: loading 1.5s infinite ease-in-out;
}
.splash-text {
    font-size: 0.5em; color: #888;
    text-transform: uppercase; letter-spacing: 1.5px;
    font-weight: 500; margin-top: 5px; min-height: 20px;
}

@keyframes pulse { 0% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.02); opacity: 0.9; } 100% { transform: scale(1); opacity: 1; } }
@keyframes loading { 0% { left: -50%; } 100% { left: 100%; } }

/* --- 3. КОНТЕЙНЕР --- */
.container {
    width: 100%; max-width: 600px; background: var(--card-bg);
    display: flex; flex-direction: column; min-height: 100dvh;
    padding-bottom: 30px; opacity: 0; transition: opacity 1s ease-in;
}
.container.loaded { opacity: 1; }

@media (min-width: 768px) {
    body { padding: 40px 20px; align-items: center; }
    .container {
        max-width: 700px; border-radius: var(--radius);
        box-shadow: 0 10px 30px rgba(0,0,0,0.5);
        min-height: auto; overflow: hidden;
    }
}

/* --- 4. ЕЛЕМЕНТИ ІНТЕРФЕЙСУ --- */
.stepper { background: #252525; border-bottom: 1px solid #333; padding: 15px 0; display: flex; justify-content: center; width: 100%; }
.stepper-inner { display: flex; justify-content: space-between; align-items: center; width: 100%; max-width: var(--content-width); padding: 0 10px; position: relative; }
.step-dot { width: 24px; height: 24px; background: #444; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: bold; color: #999; transition: all 0.3s ease; z-index: 2; }
.step-dot.active { background: var(--accent-color); color: #fff; transform: scale(1.1); }
.step-line-bg { position: absolute; top: 50%; left: 20px; right: 20px; height: 2px; background: #444; z-index: 1; transform: translateY(-50%); }

.app-title { width: 100%; text-align: center; color: #999; font-size: 1.3em; font-weight: 600; letter-spacing: 2px; text-transform: uppercase; margin-bottom: 35px; margin-top: 25px; }
.step-content { padding: 30px 20px; flex-grow: 1; animation: fadeIn 0.3s ease-out; display: flex; flex-direction: column; align-items: center; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
h2 { margin: 0 0 30px 0; font-weight: 600; font-size: 1.2em; color: #fff; border-bottom: 1px solid #333; padding-bottom: 10px; width: 100%; text-align: center; }

/* --- 5. ФОРМИ --- */
.form-group { width: 100%; max-width: var(--content-width); margin-bottom: 25px; }
label { display: block; margin-bottom: 8px; font-size: 1em; color: var(--text-label); font-weight: 500; text-align: left; }

input, select {
    width: 100%; height: 55px; padding: 0 15px;
    background: var(--input-bg); border: 1px solid var(--border-color);
    border-radius: 8px; color: #fff; font-size: 19px;
    transition: all 0.2s; -webkit-appearance: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
input:focus, select:focus { border-color: var(--accent-color); box-shadow: 0 0 0 1px var(--accent-color); background: #333; outline: none; }
input.invalid, select.invalid { border-color: var(--error-color); background-color: #3d2b2e; }
input.valid { border-color: var(--success-color); }
.validation-msg { font-size: 0.8em; color: var(--error-color); margin-top: 4px; display: none; text-align: left; }

/* 🔥 FIXED: Універсальне поле дати ("Магічна дата") */
input[type="date"] {
    position: relative;
    cursor: pointer;
    /* Якщо хочете текст по центру/справа, можна додати text-align */
}
input[type="date"]::-webkit-calendar-picker-indicator {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; height: 100%;
    opacity: 0; /* Невидима, але перехоплює кліки */
    cursor: pointer;
}

.checkbox-group { width: 100%; max-width: var(--content-width); display: flex; align-items: center; margin-top: 10px; color: #aaa; font-size: 0.9em; }
.checkbox-group input { width: 24px; height: 24px; margin-right: 10px; cursor: pointer; accent-color: var(--accent-color); appearance: auto; }
.checkbox-group a { color: var(--accent-color); text-decoration: none; border-bottom: 1px dashed var(--accent-color); }

/* --- 6. КАРТКИ ІНСТРУМЕНТІВ --- */
.instr-grid { display: flex; flex-direction: column; gap: 15px; margin-top: 10px; width: 100%; max-width: var(--content-width); }
.instr-card { background: var(--input-bg); border: 1px solid var(--border-color); padding: 15px; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; transition: 0.2s; min-height: 55px; }
.instr-card.selected { border-color: var(--accent-color); background: rgba(230, 81, 0, 0.15); }
.instr-card input { display: none; } .instr-price { color: #fff; font-weight: bold; font-size: 1em; }
.instr-check { width: 24px; height: 24px; border: 2px solid #666; border-radius: 4px; display: flex; align-items: center; justify-content: center; }
.instr-card.selected .instr-check { background: var(--accent-color); border-color: var(--accent-color); }
.instr-card.selected .instr-check::after { content: '✓'; color: #fff; font-weight: bold; }

/* Статуси інструментів */
.instr-card.disabled-red { opacity: 0.6; filter: grayscale(100%); cursor: not-allowed; background: rgba(45, 0, 0, 0.5); border-color: #5c0000; }
.instr-card.warning-yellow { border: 1px solid #ffca28; background: rgba(255, 202, 40, 0.05); }
.instr-status-msg { font-size: 0.75em; font-weight: bold; margin-top: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.instr-status-msg.red { color: #ff5252; }
.instr-status-msg.yellow { color: #ffca28; }

/* --- 7. ПІДСУМКИ --- */
.mini-summary { background: rgba(230, 81, 0, 0.1); border: 1px solid var(--accent-color); color: #fff; padding: 15px; border-radius: 8px; margin-top: 25px; font-size: 1em; line-height: 1.6; width: 100%; max-width: var(--content-width); text-align: left; }
.final-summary-container { width: 100%; max-width: var(--content-width); margin-bottom: 20px; }
.summary-box { background: #252525; border-radius: 8px; padding: 25px; border-left: 4px solid var(--accent-color); width: 100%; max-width: var(--content-width); margin-bottom: 20px;}
.sum-row { display: flex; justify-content: space-between; margin-bottom: 15px; border-bottom: 1px dashed #444; padding-bottom: 10px; align-items: baseline; }
.sum-row:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.sum-label { color: var(--text-label); font-size: 0.95em; text-align: left; } .sum-val { color: #fff; font-weight: 500; text-align: right; font-size: 1.05em; }
.total-price { font-size: 2em; text-align: center; color: var(--success-color); margin: 25px 0; font-weight: bold; }

/* --- 8. КНОПКИ --- */
.btn-group { margin-top: 40px; padding-bottom: 10px; width: 100%; max-width: var(--content-width); display: flex; gap: 15px; }
button { flex: 1; padding: 0 16px; height: 55px; border: none; border-radius: 8px; font-size: 19px; font-weight: 600; cursor: pointer; transition: opacity 0.2s; -webkit-appearance: none; display: flex; align-items: center; justify-content: center; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent-color); color: #fff; }
.btn-secondary { background: transparent; border: 1px solid #666; color: #ccc; }
.btn-success { background: var(--success-color); color: #000; }
.hidden { display: none !important; }
.loader { width: 18px; height: 18px; border: 3px solid #fff; border-top-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; margin-right: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }
.test-email-btn { background: transparent; color: #007bff; border: 1px solid #007bff; font-size: 0.8em; padding: 5px 10px; border-radius: 4px; margin-top: 5px; cursor: pointer; width: auto; height: auto; }
.test-email-btn:hover { background: rgba(0, 123, 255, 0.1); }

.studio-input-group { display: flex; gap: 10px; }
.studio-input-group select { flex-grow: 1; }
.btn-info { width: auto; padding: 0 15px; background: transparent; border: 1px solid var(--accent-color); color: var(--accent-color); font-size: 0.9em; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.btn-info:hover { background: rgba(230, 81, 0, 0.1); }
.btn-info:disabled { border-color: #444; color: #666; cursor: default; background: transparent; }

/* --- 9. MODALS & OVERLAYS (UNIFIED) --- */

/* Базовий оверлей для ВСІХ модальних вікон */
/* Z-Index 10000+ щоб перекривати Splash (9999) */
.overlay, .modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 20000; /* Максимальний пріоритет */
    display: none; /* JS перемкне на flex */
    align-items: center; justify-content: center;
    backdrop-filter: blur(5px);
}

/* Якщо ми використовуємо клас .active для анімації (Studio Info) */
.modal-overlay.active { display: flex; animation: fadeIn 0.3s; }
.overlay.active { display: flex; animation: fadeIn 0.3s; }

/* Контент модальних вікон (Базовий стиль) */
.overlay-content, .modal-card {
    background: #1e1e1e; padding: 25px; border-radius: 12px;
    border: 1px solid #333; box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    position: relative; width: 100%; max-width: 450px;
    text-align: center;
}

/* Специфічні стилі для вікна "Успіху" */
.overlay-content {
    box-shadow: 0 10px 40px rgba(0,200,83, 0.2);
}

/* Специфічні стилі для вікна "Інфо про студію" */
.modal-card {
    padding: 0; border-radius: 16px; overflow: hidden;
    transform: translateY(20px); transition: 0.3s;
}
.modal-overlay.active .modal-card { transform: translateY(0); }

/* --- ЕЛЕМЕНТИ МОДАЛОК --- */
.modal-close { position: absolute; top: 10px; right: 10px; width: 35px; height: 35px; background: rgba(0,0,0,0.5); color: #fff; border-radius: 50%; border: none; font-size: 24px; line-height: 1; cursor: pointer; z-index: 2; display: flex; align-items: center; justify-content: center; }
.modal-img-container { position: relative; width: 100%; height: 200px; background: #2d2d2d; overflow: hidden; }
.modal-img-container::before { content: ""; position: absolute; top: 0; left: -100%; width: 100%; height: 100%; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent); animation: shimmer 1.5s infinite; }
@keyframes shimmer { 100% { left: 100%; } }
.modal-img-container img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.4s ease-in; position: relative; z-index: 2; }
.modal-img-container img[src] { opacity: 1; }
.modal-title-badge { position: absolute; top: 10px; left: 15px; background: var(--accent-color); color: #fff; padding: 3px 10px; border-radius: 5px; font-size: 0.95em; box-shadow: 0 4px 10px rgba(0,0,0,0.3); }

.modal-content { padding: 20px; text-align: left; color: #ddd; }
.modal-content h3 { color: var(--accent-color); font-size: 1em; margin: 0 0 10px 0; text-transform: uppercase; letter-spacing: 1px; border-bottom: none; text-align: left;}
.modal-content p { font-size: 0.95em; line-height: 1.5; margin-bottom: 20px; color: #ccc; }
.modal-content pre { background: #252525; padding: 15px; border-radius: 8px; white-space: pre-wrap; font-family: inherit; font-size: 0.9em; border-left: 3px solid #555; color: #bbb; margin: 0; }
.modal-divider { height: 1px; background: #333; margin: 20px 0; }
.modal-footer { padding: 0 20px 20px 20px; }
.success-icon { font-size: 50px; margin-bottom: 20px; }
.sub-text { color: #888; font-size: 0.9em; margin-top: 10px; }
.btn-close-window { margin-top: 20px; width: 100%; background: #333; color: #fff; border: 1px solid #555; }
.pulse-btn { animation: btnPulse 2s infinite; box-shadow: 0 0 0 0 rgba(230, 81, 0, 0.7); }
@keyframes btnPulse { 0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(230, 81, 0, 0.7); } 70% { transform: scale(1.02); box-shadow: 0 0 0 10px rgba(230, 81, 0, 0); } 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(230, 81, 0, 0); } }

/* --- 10. СТАТУСИ У СПИСКАХ --- */
option.optimal { color: #00e676; font-weight: bold; background-color: #1e3a2a; }
option.standard { color: #ffffff; }
option.restricted { color: #ff5252; font-weight: bold; background-color: #3d2b2e; }

/* --- 11. ADMIN UI --- */
.hidden-force { display: none !important; }

.admin-override-box {
    margin-top: 15px; padding: 10px; background: #4a1e1e;
    border: 1px solid #ff4444; border-radius: 8px;
    display: flex; align-items: center; gap: 10px;
}

.admin-client-controls { display: flex; gap: 10px; margin-bottom: 20px; }
.btn-admin-search { flex: 1; background: #333; border: 1px solid #666; color: white; padding: 12px; border-radius: 8px; font-weight: bold; cursor: pointer; }
.btn-admin-new { flex: 1; background: #2c5e2e; border: 1px solid #4CAF50; color: white; padding: 12px; border-radius: 8px; font-weight: bold; cursor: pointer; }

.admin-success-details {
    text-align: left; background: #111; padding: 15px; border-radius: 8px;
    margin: 15px 0; font-family: monospace; font-size: 14px; line-height: 1.5; border: 1px solid #333;
}
.admin-action-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 15px; }
.btn-admin-action { padding: 10px; border-radius: 6px; border: none; cursor: pointer; font-size: 14px; color: #fff; }

.admin-badge {
    position: fixed;
    top: 10px;
    right: 10px;
    background: #ff9800; /* Помаранчевий */
    color: #000;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    z-index: 9000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
    text-transform: uppercase;
    display: none; /* JS покаже це */
}

.admin-override-box {
    margin-top: 15px;
    padding: 12px;
    background: #2d1b1b; /* Темний фон */
    border: 1px solid #552222;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between; /* Розсунути текст і кнопку */
}
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #444;
    transition: .4s;
    border-radius: 34px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 18px; width: 18px;
    left: 4px; bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

/* Стан: Активний */
input:checked + .slider {
    background-color: #ff5252; /* Червоний - "Override" */
}
input:checked + .slider:before {
    transform: translateX(24px);
}