/* ==========================================================================
   FILE PURPOSE: Central CSS stylesheet for the Multi-Page Onboarding Engine.
                 Handles global styling, custom variables, the centered card 
                 layout, interactive states, and transition animations.
                 RTL LOGIC: Utilizes CSS Logical Properties for seamless LTR/RTL support.
   ========================================================================== */

/* ==========================================================================
   VARIABLES BLOCK (Central Controls)
   ========================================================================== */
:root {
    /* Typography */
    --font-family-main: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    
    /* Color Palette */
    --color-bg: #f8fafc; /* Very light gray / soft slate */
    --color-card-bg: #ffffff; /* Pure white */
    --color-text-main: #334155; /* Dark Charcoal */
    --color-text-muted: #64748b; /* Medium-light gray */
    --color-accent: #4f46e5; /* Deep Royal Purple/Blue for trust */
    --color-accent-hover: #4338ca;
    --color-error: #ef4444; /* Red for inline errors */
    
    /* Elements */
    --color-border: #e2e8f0;
    --border-radius-card: 16px;
    --border-radius-input: 8px;
    
    /* Animation & Timings */
    --transition-speed: 400ms; /* Speed of the page fade and hover effects */
}

/* ==========================================================================
   GLOBAL RULES & RESET
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family-main);
    background-color: var(--color-bg);
    color: var(--color-text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    padding: 20px; /* Important for mobile spacing */
    opacity: 0; 
    animation: fadeIn var(--transition-speed) ease-out forwards;
    transition: background-color var(--transition-speed) ease;
}

body.fade-out {
    opacity: 0;
    transform: scale(0.98);
    transition: all var(--transition-speed) ease-in;
}

/* ==========================================================================
   LAYOUT: CENTERED CARD
   ========================================================================== */
.cards-wrapper {
    position: relative;
    width: 100%;
    max-width: 500px;
    z-index: 10;
}

.card-container {
    background-color: var(--color-card-bg);
    width: 100%;
    padding: 40px;
    border-radius: var(--border-radius-card);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    text-align: center; 
    transform: translateY(10px);
    animation: slideUp var(--transition-speed) ease-out forwards;
}

/* ==========================================================================
   TYPOGRAPHY & HEADINGS
   ========================================================================== */
.enrolment-label {
    display: inline-block;
    background-color: #f1f5f9;
    color: var(--color-text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 6px 12px;
    border-radius: 50px; 
    margin-bottom: 24px;
}

h1 {
    font-size: 1.75rem;
    font-weight: 800;
    margin-bottom: 8px;
    color: var(--color-text-main);
}

h2 {
    font-size: 1rem;
    font-weight: 400;
    color: var(--color-text-muted);
    margin-bottom: 32px;
}

/* ==========================================================================
   DYNAMIC MIDDLE AREA (Inputs & Polls)
   ========================================================================== */
.dynamic-content {
    margin-bottom: 32px;
    text-align: start; /* לוגי במקום left */
}

.modern-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--color-border);
    border-radius: var(--border-radius-input);
    font-family: var(--font-family-main);
    font-size: 1rem;
    color: var(--color-text-main);
    background-color: transparent;
    transition: all 0.2s ease;
    margin-bottom: 16px;
}

.modern-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); 
}

/* NEW: Validation error state for inputs */
.modern-input.input-error {
    border-color: var(--color-error);
    background-color: rgba(239, 68, 68, 0.02);
}

.modern-input.input-error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.poll-option {
    display: block;
    cursor: pointer;
    margin-bottom: 12px;
}

.poll-option input[type="radio"] {
    position: absolute;
    opacity: 0; 
}

.poll-box {
    display: block;
    padding: 16px;
    border: 2px solid var(--color-border);
    border-radius: var(--border-radius-input);
    transition: all 0.2s ease;
    text-align: center;
    font-weight: 500;
}

.poll-option:hover .poll-box {
    background-color: #f8fafc;
}

.poll-option input[type="radio"]:checked + .poll-box {
    border-color: var(--color-accent);
    color: var(--color-accent);
    background-color: rgba(79, 70, 229, 0.05);
}

.error-message {
    color: var(--color-error);
    font-size: 0.85rem;
    margin-top: -8px;
    margin-bottom: 16px;
    display: none; 
}

/* ==========================================================================
   ACTION BUTTONS
   ========================================================================== */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.btn-primary {
    background-color: var(--color-accent);
    color: #ffffff;
    border: none;
    padding: 14px 32px;
    border-radius: var(--border-radius-input);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    width: 70%;
    transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--color-accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.2);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0); 
}

.btn-secondary {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: underline transparent;
    transition: color 0.2s ease;
}

.btn-secondary:hover {
    color: var(--color-text-main);
}

/* ==========================================================================
   FLOATING BUTTONS & PANELS (Theme & Chat)
   ========================================================================== */
.floating-btn {
    position: fixed;
    bottom: 30px;
    width: 60px;
    height: 60px;
    background-color: var(--color-accent);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    z-index: 900;
    transition: transform var(--transition-speed) ease, 
                background-color var(--transition-speed) ease,
                box-shadow var(--transition-speed) ease;
}

.floating-btn:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
    filter: brightness(1.1);
}

.floating-btn svg {
    transition: transform 0.4s ease;
}

/* הצדדים הפיזיים נשמרים כיוון שאנו רוצים שההגדרות ישארו בשמאל המסך תמיד */
#btnOpenSettings { left: 30px; }
#btnOpenSettings:hover svg { transform: rotate(90deg); }

#btnOpenChat { right: 30px; }
#btnOpenChat:hover svg { transform: scale(1.1) rotate(-5deg); }

.floating-panel {
    position: absolute;
    top: 40px; 
    background-color: var(--color-card-bg);
    width: 100%;
    max-width: 320px; 
    border-radius: var(--border-radius-card);
    padding: 24px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 400ms cubic-bezier(0.165, 0.84, 0.44, 1);
}

.floating-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(0) scale(1);
}

#settingsPanel {
    left: -40px;
    box-shadow: -10px 25px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0,0,0,0.03);
    transform: translateX(-20px) scale(0.95);
}

#chatPanel {
    right: -40px;
    box-shadow: 10px 25px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0,0,0,0.03);
    transform: translateX(20px) scale(0.95);
}

.floating-panel h3 {
    color: var(--color-text-main);
    font-weight: 800;
    margin-bottom: 20px;
    text-align: start; /* לוגי במקום left */
    font-size: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: color 0.2s;
    line-height: 1;
}

.btn-close:hover { color: var(--color-error); }

.chat-content p {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 16px;
    text-align: start; /* לוגי במקום left */
}

.status-pill {
    display: inline-block;
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--color-error);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.form-group {
    margin-bottom: 16px;
    text-align: start; /* לוגי במקום left */
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--color-text-main);
    font-weight: 600;
    margin-bottom: 6px;
}

/* ==========================================================================
   ANIMATIONS
   ========================================================================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(10px); }
    to { transform: translateY(0); }
}

/* Restore the mobile centering behavior */
@media (max-width: 768px) {
    .floating-panel {
        position: fixed;
        left: 50% !important;
        right: auto !important;
        top: 50% !important;
        transform: translate(-50%, -50%) scale(0.95) !important;
    }
    .floating-panel.active {
        transform: translate(-50%, -50%) scale(1) !important;
    }
}