/**
 * Registration v2 - Windows XP Luna Style
 * Company colors: #000000, #FFFFFF, #1973E9, #004592
 * Based on XP.css + Bliss-inspired background
 */

/* === Company Color Variables === */
:root {
    --xp-black: #000000;
    --xp-white: #FFFFFF;
    --xp-blue: #1973E9;
    --xp-blue-dark: #004592;
    --xp-blue-light: #4d9eff;
    --xp-beige: #ece9d8;
    --xp-silver: #dfdfdf;
    --xp-gray: #919b9c;
}

/* === Body & Bliss Background === */
.xp-body {
    font-family: Tahoma, 'Segoe UI', Geneva, Verdana, sans-serif;
    font-size: 11px;
    color: var(--xp-black);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    position: relative;
}

/* Bliss wallpaper background */
.bliss-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background: url('/static/media/wallaper.webp') center center / cover no-repeat;
    pointer-events: none;
}

/* === Container === */
.container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    z-index: 1;
}

/* На мобильных не центрируем по вертикали — форма сверху, контент скроллится (нет обрезки снизу) */
@media (max-width: 768px) {
    .container {
        align-items: flex-start;
        padding-top: 12px;
        padding-bottom: 24px;
        min-height: 100vh;
    }
    .xp-window .window-body {
        overflow-y: visible;
        max-height: none;
    }
    .xp-window {
        max-height: none;
    }
}

/* === Main XP Window - Company Colors === */
.xp-window {
    width: 100%;
    max-width: 520px;
    box-shadow: 
        4px 4px 0 rgba(0,0,0,0.2),
        8px 8px 20px rgba(0,0,0,0.3);
    animation: windowAppear 0.6s ease-out;
}

@keyframes windowAppear {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Title bar - Luna blue with company colors */
.xp-window .title-bar {
    background: linear-gradient(180deg, var(--xp-blue-light) 0%, var(--xp-blue) 50%, var(--xp-blue-dark) 100%);
    border-bottom: 1px solid var(--xp-blue-dark);
}

.xp-window .title-bar-text {
    color: var(--xp-white);
    font-weight: bold;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.3);
}

.window-icon {
    margin-right: 6px;
    font-size: 14px;
}

/* Title bar buttons - XP Luna style: gloss, blue + red close, Safari-compatible icons */
.xp-window .title-bar-controls button {
    position: relative;
    background: linear-gradient(180deg, #6eb4ff 0%, #1973E9 50%, #004592 100%) !important;
    background-image: none !important;
    border: 1px solid #003d7a;
    box-shadow: 0 1px 0 rgba(255,255,255,0.3) inset, 0 1px 1px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.xp-window .title-bar-controls button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 45%;
    background: linear-gradient(180deg, rgba(255,255,255,0.35) 0%, rgba(255,255,255,0.08) 100%);
    pointer-events: none;
}

.xp-window .title-bar-controls button:hover {
    background: linear-gradient(180deg, #5aa3f0 0%, #1565c7 50%, #003d7a 100%) !important;
}

.xp-window .title-bar-controls button.btn-close {
    background: linear-gradient(180deg, #ff9a6b 0%, #e74c3c 50%, #c0392b 100%) !important;
    border-color: #a93226;
}

.xp-window .title-bar-controls button.btn-close:hover {
    background: linear-gradient(180deg, #ffb088 0%, #e74c3c 50%, #a93226 100%) !important;
}

.xp-window .title-bar-controls .btn-icon {
    color: var(--xp-white);
    font-size: 14px;
    line-height: 1;
    font-weight: bold;
    position: relative;
    z-index: 1;
}

/* Select focus - company blue */
select:focus {
    color: var(--xp-white) !important;
    background-color: var(--xp-blue) !important;
}

/* Tree view / links focus */
ul.tree-view a:focus {
    background-color: var(--xp-blue) !important;
    color: var(--xp-white) !important;
}

/* === Card Header === */
.card-header {
    text-align: left;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--xp-gray);
}

.header-logo {
    display: block;
    max-width: 480px;
    max-height: 240px;
    margin: 0 auto 12px;
    object-fit: contain;
}

.xp-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--xp-blue-dark);
    margin: 0 0 6px 0;
}

.xp-subtitle {
    color: var(--xp-gray);
    font-size: 11px;
    margin: 0;
}

.xp-subtitle-large {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--xp-blue-dark);
}

/* === Form Layout === */
.registration-form fieldset {
    margin-bottom: 16px;
}

.registration-form legend {
    font-weight: bold;
}

/* Age row - horizontal radio buttons */
.age-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 4px;
}

.age-row .field-row {
    margin: 0;
}

/* Income grid */
.income-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.income-option {
    margin: 0 !important;
}

@media (max-width: 600px) {
    .income-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .age-row {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}

/* Убираем зум iOS при фокусе на input (font-size < 16px вызывает авто-зум) */
@media (max-width: 768px) {
    .xp-window input,
    .xp-window textarea,
    .xp-window select {
        font-size: 16px !important;
    }
    /* Достаточная высота и отступы, чтобы текст не обрезался */
    .xp-window input[type="text"],
    .xp-window input[type="number"],
    .xp-window input[type="url"] {
        min-height: 44px;
        padding: 10px 12px;
        line-height: 1.25;
        box-sizing: border-box;
    }
    .xp-window textarea {
        min-height: 60px;
        padding: 10px 12px;
        line-height: 1.25;
        box-sizing: border-box;
    }
}

/* Form actions */
.form-actions {
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

.xp-submit-btn {
    background: linear-gradient(180deg, var(--xp-blue-light), var(--xp-blue)) !important;
    color: var(--xp-white) !important;
    font-weight: bold;
    min-width: 140px;
}

.xp-submit-btn:hover {
    background: linear-gradient(180deg, var(--xp-blue), var(--xp-blue-dark)) !important;
}

.xp-cancel-btn {
    min-width: 80px;
}

/* Status bar */
.status-bar {
    margin-top: 12px;
}

.status-bar-field {
    font-size: 10px;
    color: var(--xp-gray);
}

/* === Loading Screen - XP Style === */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('/static/media/wallaper.webp') center center / cover no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-window {
    background: var(--xp-beige);
    box-shadow: inset -1px -1px #0a0a0a, inset 1px 1px #fff, inset -2px -2px grey, inset 2px 2px #dfdfdf;
    padding: 3px;
    min-width: 280px;
}

.loading-title-bar {
    background: linear-gradient(180deg, var(--xp-blue-light), var(--xp-blue));
    padding: 4px 8px;
    color: var(--xp-white);
    font-weight: bold;
    font-size: 11px;
}

.loading-body {
    padding: 24px;
    text-align: center;
}

/* Loading indicator - pulsing dots (no rotation) */
.xp-loading-dots {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 12px;
}

.xp-loading-dots span {
    width: 12px;
    height: 12px;
    background: var(--xp-blue);
    border-radius: 50%;
    animation: xpDotPulse 1.2s ease-in-out infinite;
}

.xp-loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.xp-loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes xpDotPulse {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1); }
}

.loading-body p {
    margin: 0 0 12px 0;
    color: var(--xp-black);
}

/* Loading screen progress bar */
.xp-progress {
    width: 100%;
    height: 20px;
    margin-top: 12px;
}

progress {
    accent-color: var(--xp-blue);
}

/* Form progress bar - XP style, updates after each answered question */
.form-progress-bar {
    width: 100%;
    margin-top: 16px;
}

.form-progress-track {
    height: 18px;
    background: linear-gradient(180deg, #d4d8dc 0%, #b8bcc0 50%, #9ca0a4 100%);
    border: 1px solid #808080;
    box-shadow: inset 2px 2px 3px rgba(0,0,0,0.15), inset -1px -1px 1px rgba(255,255,255,0.4);
    border-radius: 3px;
    overflow: hidden;
}

.form-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(180deg, #6bb3ff 0%, #1973E9 50%, #004592 100%);
    border-radius: 2px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.3);
    transition: width 0.4s ease;
}

.form-progress-text {
    display: block;
    font-size: 10px;
    color: var(--xp-gray);
    margin-top: 4px;
}

/* === Error states === */
.form-input.error,
.form-textarea.error,
input.error {
    border-color: #c00 !important;
    box-shadow: 0 0 0 1px #c00 !important;
}

/* === Responsive === */
@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    .xp-window {
        max-width: 100%;
    }
    
    .title-bar-text {
        font-size: 10px;
    }
.xp-body, .xp-window, .window-body {
    scrollbar-width: auto;
    scrollbar-color: #1973E9 #ece9d8;
}
}

/* === XP-style Scrollbar === */
.xp-body ::-webkit-scrollbar,
.xp-window ::-webkit-scrollbar,
.window-body::-webkit-scrollbar {
    width: 16px;
    height: 16px;
}

.xp-body ::-webkit-scrollbar-track,
.xp-window ::-webkit-scrollbar-track,
.window-body::-webkit-scrollbar-track {
    background: linear-gradient(90deg, #ece9d8 0%, #d4d0c8 50%, #ece9d8 100%);
    border: 1px solid #848484;
    box-shadow: inset 1px 1px 0 #fff;
}

.xp-body ::-webkit-scrollbar-thumb,
.xp-window ::-webkit-scrollbar-thumb,
.window-body::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #6eb4ff 0%, #1973E9 30%, #004592 100%);
    border: 1px solid #003d7a;
    border-radius: 3px;
    min-height: 24px;
    box-shadow: 0 1px 0 rgba(255,255,255,0.3) inset;
}

.xp-body ::-webkit-scrollbar-thumb:hover,
.xp-window ::-webkit-scrollbar-thumb:hover,
.window-body::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #5aa3f0 0%, #1565c7 30%, #003d7a 100%);
}

.xp-body ::-webkit-scrollbar-button,
.xp-window ::-webkit-scrollbar-button,
.window-body::-webkit-scrollbar-button {
    width: 16px;
    height: 16px;
    background: linear-gradient(180deg, #6eb4ff 0%, #1973E9 50%, #004592 100%);
    border: 1px solid #003d7a;
    box-shadow: 0 1px 0 rgba(255,255,255,0.3) inset;
}

.xp-body ::-webkit-scrollbar-button:hover,
.xp-window ::-webkit-scrollbar-button:hover,
.window-body::-webkit-scrollbar-button:hover {
    background: linear-gradient(180deg, #5aa3f0 0%, #1565c7 50%, #003d7a 100%);
}

.xp-body ::-webkit-scrollbar-button:vertical:increment {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23fff' d='M8 10l4-4H4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
}

.xp-body ::-webkit-scrollbar-button:vertical:decrement {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23fff' d='M8 6l-4 4h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
}
