/**
 * Auth Modal CSS - Dark/Light Theme
 * Login/Register modal overlay styling
 * Uses CSS variables from shared.css
 */

/* ===== OVERLAY ===== */
.tt-auth-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000001;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.tt-auth-overlay.active {
    display: flex;
}

/* ===== MODAL BOX ===== */
.tt-auth-modal {
    background: var(--card-bg);
    border-radius: 16px;
    max-width: 400px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    position: relative;
    animation: modalSlideIn var(--duration-normal) var(--ease-spring);
    box-shadow: var(--shadow-medium);
}

/* Keyframe moved to animations.css */

/* ===== CLOSE BUTTON ===== */
.tt-auth-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    background: var(--bg-secondary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: background 0.2s;
}

.tt-auth-close:hover {
    background: var(--bg-tertiary);
}

/* ===== TITLE ===== */
.tt-auth-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
    text-align: center;
}

/* ===== TABS ===== */
.tt-auth-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 4px;
}

.tt-auth-tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: background-color var(--duration-fast) var(--ease-default), color var(--duration-fast) var(--ease-default);
}

.tt-auth-tab:hover {
    color: var(--text-secondary);
}

.tt-auth-tab.active {
    background: var(--accent, #fe2c55);
    color: #fff;
}

/* ===== FORM ===== */
.tt-auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tt-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tt-form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.tt-form-group input,
.tt-form-group select {
    width: 100%;
    padding: 12px 14px;
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 15px;
    transition: border-color 0.2s, background-color 0.2s;
}

.tt-form-group input::placeholder {
    color: var(--input-placeholder);
}

.tt-form-group input:focus,
.tt-form-group select:focus {
    outline: none;
    border-color: var(--accent, #fe2c55);
    background-color: var(--input-focus-bg);
}

.tt-form-group select {
    cursor: pointer;
    appearance: none;
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

/* Select dropdown arrow SVG - theme-specific */
[data-theme="light"] .tt-form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
}
[data-theme="dark"] .tt-form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a3a3a3' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
}

.tt-form-group select option {
    background: var(--card-bg);
    color: var(--text-primary);
}

/* Form row for side-by-side fields */
.tt-form-row {
    display: flex;
    gap: 12px;
}

.tt-form-half {
    flex: 1;
}

/* ===== ERROR MESSAGE ===== */
.tt-form-error {
    color: #dc2626;
    font-size: 13px;
    padding: 10px 12px;
    background: rgba(220, 38, 38, 0.1);
    border-radius: 8px;
    display: none;
}

.tt-form-error.visible {
    display: block;
}

/* ===== SUBMIT BUTTON ===== */
.tt-auth-submit {
    width: 100%;
    padding: 14px 20px;
    background: var(--accent, #fe2c55);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
    margin-top: 8px;
}

.tt-auth-submit:hover:not(:disabled) {
    transform: translateY(-1px);
    opacity: 0.9;
}

.tt-auth-submit:active:not(:disabled) {
    transform: translateY(0);
}

.tt-auth-submit:disabled {
    opacity: 0.6;
    cursor: wait;
}

.tt-auth-submit .tt-submit-loading {
    display: none;
}

.tt-auth-submit.loading .tt-submit-text {
    display: none;
}

.tt-auth-submit.loading .tt-submit-loading {
    display: inline;
}

/* ===== FORGOT PASSWORD LINK ===== */
.tt-forgot-link {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    padding: 4px 0;
    text-align: center;
    width: 100%;
    transition: color 0.2s;
}

.tt-forgot-link:hover {
    color: var(--accent, #fe2c55);
}

/* ===== SUCCESS MESSAGE ===== */
.tt-form-success {
    color: #22c55e;
    font-size: 14px;
    padding: 12px 14px;
    background: rgba(34, 197, 94, 0.1);
    border-radius: 8px;
    text-align: center;
    line-height: 1.4;
}

/* ===== REGISTER WIZARD STEPS ===== */
.tt-register-step {
    animation: stepFadeIn var(--duration-fast) var(--ease-out);
}

/* Keyframe moved to animations.css */

.tt-step-subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 16px;
    text-align: center;
}

/* 3-column row for birth date + gender */
.tt-form-row-3 {
    display: flex;
    gap: 10px;
}

.tt-form-row-3 .tt-form-group {
    flex: 1;
}

.tt-form-row-3 select {
    padding: 12px 8px;
    padding-right: 28px;
    font-size: 14px;
    background-position: right 8px center;
}

/* ===== CHECKBOX ===== */
.tt-form-checkbox {
    margin-top: 8px;
}

.tt-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    line-height: 1.4;
}

.tt-checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.tt-checkbox-custom {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    border: 2px solid var(--input-border);
    border-radius: 4px;
    background-color: var(--input-focus-bg);
    transition: background-color var(--duration-fast) var(--ease-default), border-color var(--duration-fast) var(--ease-default);
    position: relative;
    margin-top: 1px;
}

.tt-checkbox-label input[type="checkbox"]:checked + .tt-checkbox-custom {
    background: var(--accent, #fe2c55);
    border-color: var(--accent, #fe2c55);
}

.tt-checkbox-label input[type="checkbox"]:checked + .tt-checkbox-custom::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 5px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.tt-checkbox-label input[type="checkbox"]:focus + .tt-checkbox-custom {
    box-shadow: 0 0 0 2px rgba(254, 44, 85, 0.2);
}

.tt-checkbox-text {
    color: var(--text-muted);
}

.tt-checkbox-text a {
    color: var(--accent, #fe2c55);
    text-decoration: none;
    font-weight: 500;
}

.tt-checkbox-text a:hover {
    text-decoration: underline;
}

/* Step indicator dots */
.tt-step-indicator {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.tt-step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-color);
    transition: background 0.3s, transform 0.3s;
}

.tt-step-dot.active {
    background: var(--accent, #fe2c55);
    transform: scale(1.2);
}

/* Form buttons row (back + submit) */
.tt-form-buttons {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.tt-auth-back {
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tt-auth-back:hover {
    background: var(--bg-tertiary);
}

.tt-form-buttons .tt-auth-submit {
    flex: 1;
    margin-top: 0;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
    .tt-auth-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .tt-auth-modal {
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        max-height: 85dvh;
        max-height: 85vh; /* fallback for older browsers */
        padding: 12px 12px calc(20px + env(safe-area-inset-bottom, 0px));
        animation: bottomSheetIn var(--duration-normal) var(--ease-spring);
    }

    @supports (max-height: 85dvh) {
        .tt-auth-modal {
            max-height: 85dvh;
        }
    }

    .tt-auth-title {
        font-size: 20px;
    }

    .tt-form-row {
        flex-direction: column;
        gap: 16px;
    }

    /* Keep 3-column row on mobile */
    .tt-form-row-3 {
        flex-direction: row;
        gap: 8px;
    }

    .tt-form-row-3 select {
        padding: 12px 6px;
        padding-right: 24px;
        font-size: 13px;
        background-position: right 6px center;
    }

    .tt-form-row-3 label {
        font-size: 11px;
    }

    .tt-form-half {
        width: 100%;
    }
}

/* Hide sheet handle on desktop */
@media (min-width: 769px) {
    .tt-auth-modal .sheet-handle {
        display: none;
    }
}

/* Mobile keyboard handling - ensure focused input is visible */
@media (max-height: 500px) {
    .tt-auth-modal {
        max-height: 100vh;
        border-radius: 0;
    }
}

/* PWA standalone — modal full-width pe iPhone */
@media (display-mode: standalone) {
    .tt-auth-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .tt-auth-modal {
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        padding: 16px 16px calc(24px + env(safe-area-inset-bottom, 0px));
    }
}

/* iOS PWA keyboard open — form compact */
.tt-auth-modal.ios-keyboard-open {
    padding: 12px 12px;
    border-radius: 12px;
}

.tt-auth-modal.ios-keyboard-open .tt-auth-title {
    font-size: 18px;
    margin-bottom: 12px;
}

.tt-auth-modal.ios-keyboard-open .tt-auth-tabs {
    margin-bottom: 14px;
    padding: 3px;
}

.tt-auth-modal.ios-keyboard-open .tt-auth-tab {
    padding: 8px 12px;
    font-size: 13px;
}

.tt-auth-modal.ios-keyboard-open .tt-auth-form {
    gap: 10px;
}

.tt-auth-modal.ios-keyboard-open .tt-form-group input,
.tt-auth-modal.ios-keyboard-open .tt-form-group select {
    padding: 10px 12px;
    font-size: 14px;
}

.tt-auth-modal.ios-keyboard-open .tt-auth-submit {
    padding: 12px 16px;
    margin-top: 4px;
}

.tt-auth-modal.ios-keyboard-open .tt-form-group label {
    font-size: 12px;
}

.tt-auth-modal.ios-keyboard-open .tt-auth-close {
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
}

/* ===== EMAIL VERIFICATION MESSAGE ===== */
.tt-verification-message {
    text-align: center;
    padding: 32px 16px;
    display: none;
}

.tt-verification-message .tt-verify-icon {
    font-size: 56px;
    margin-bottom: 20px;
    color: #22c55e;
}

.tt-verification-message h3 {
    font-size: 22px;
    font-weight: 600;
    margin: 0 0 16px 0;
    color: var(--text-primary);
}

.tt-verification-message p {
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1.5;
    margin: 0;
}

.tt-verification-message .tt-email-highlight {
    color: var(--text-primary);
    font-weight: 500;
}

/* Login error with resend link */
.tt-auth-error a {
    color: var(--accent, #fe2c55);
    text-decoration: underline;
}

.tt-auth-error a:hover {
    opacity: 0.8;
}
