/* =========================================
   VARIABLES & THEME CONFIGURATION
   ========================================= */
:root {
    --dark-bg: #0a0a0a;
    --dark-panel: #111111;
    --dark-text: #e0e0e0;
    --dark-accent: #ff0038;
    --dark-accent-glow: rgba(255, 0, 56, 0.3);
    --creative-accent: #ff00ff;
    --creative-accent-glow: rgba(255, 0, 255, 0.3);
    --light-bg: #000000;
    --light-panel: #000000;
    --light-text: #00ff00;
    --light-accent: #00ff00;
    --light-accent-glow: rgba(0, 255, 0, 0.3);
}

[data-theme="dark"] {
    --bg: var(--dark-bg);
    --panel: var(--dark-panel);
    --text: var(--dark-text);
    --accent: var(--dark-accent);
    --accent-glow: var(--dark-accent-glow);
}

[data-theme="dark"].persona-creative {
    --accent: var(--creative-accent);
    --accent-glow: var(--creative-accent-glow);
}

[data-theme="light"] {
    --bg: var(--light-bg);
    --panel: var(--light-panel);
    --text: var(--light-text);
    --accent: var(--light-accent);
    --accent-glow: var(--light-accent-glow);
}

/* =========================================
   GLOBAL STYLES
   ========================================= */
body {
    font-family: 'Rajdhani', sans-serif;
    letter-spacing: 0.1rem;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: color 0.3s ease;
    overflow: hidden;
    background-attachment: fixed;
    transform: translateZ(0);
}

a {
    color: white;
}

[data-theme="dark"] body {
    font-family: 'Rajdhani', sans-serif;
    font-size: 18px;
    letter-spacing: 0.1rem;
}

[data-theme="light"] body {
    font-family: 'Share Tech Mono', monospace;
}

[data-theme="dark"].persona-creative body {
    font-family: 'Quicksand', sans-serif;
    font-size: 16px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* =========================================
   CHAT INTERFACE STYLES (index.html)
   ========================================= */
.main-wrapper {
    width: 100%;
    max-width: 900px;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
}

header {
    padding: 1.5rem;
    text-align: center;
    position: relative;
}

h1 {
    margin: 0;
    color: var(--accent);
    font-family: 'Orbitron', sans-serif;
    font-size: 2.4rem;
    font-weight: 700;
    letter-spacing: 0.2rem;
    text-transform: uppercase;
    text-shadow: 0 0 10px var(--accent-glow);
}

.tagline {
    font-size: 1rem;
    opacity: 0.8;
    letter-spacing: 0.2rem;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 2rem 100px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
}

.chat-container::-webkit-scrollbar {
    width: 4px;
    background-color: transparent;
}

.chat-container::-webkit-scrollbar-thumb {
    background-color: var(--accent);
    border-radius: 0;
}

.message {
    max-width: 65%;
    padding: 1.2rem 1.5rem;
    border-radius: 12px;
    line-height: 1.6;
    position: relative;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    margin-bottom: 1.5rem;
}

.user-message {
    align-self: flex-end;
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 0;
    clip-path: polygon(0% 0%, 100% 0%, 100% 75%, 95% 100%, 0% 100%);
}

[data-theme="light"] .user-message {
    color: #000;
}

.ai-message {
    align-self: flex-start;
    background: var(--panel);
    border: 1px solid var(--accent);
    border-bottom-left-radius: 0;
    clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 5% 100%, 0% 75%);
}

.input-container {
    position: sticky;
    bottom: 0;
    padding: 20px 2rem;
    background: var(--bg);
    z-index: 10;
}

.input-area {
    display: flex;
    align-items: flex-end;
    background: var(--panel);
    border-radius: 26px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3),
                0 0 15px var(--accent-glow);
    border: 1px solid var(--accent);
    overflow: hidden;
}

#message-input {
    flex: 1;
    padding: 1rem 1.5rem;
    border: none;
    background: transparent;
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    resize: none;
    overflow-y: hidden;
    line-height: 1.5;
    height: auto;
    min-height: 24px;
    max-height: 150px;
}

#send-button {
    padding: 0 1.8rem;
    background: var(--accent);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: bold;
    font-size: 1.1rem;
    transition: all 0.2s;
}

[data-theme="light"] #send-button {
    color: #000;
}

.theme-toggle {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    font-size: 1.5rem;
    z-index: 100;
}

.typing-indicator {
    align-self: flex-start;
    color: var(--accent);
    font-style: italic;
    display: none;
    margin-left: 1rem;
    margin-bottom: 1.5rem;
}

.pulse {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* Corner Decorations */
.corner-decoration {
    position: absolute;
    width: 100px;
    height: 100px;
    border: 2px solid var(--accent);
    opacity: 0.3;
}

.corner-tl { top: 20px; left: 20px; border-right: none; border-bottom: none; }
.corner-tr { top: 20px; right: 20px; border-left: none; border-bottom: none; }
.corner-bl { bottom: 120px; left: 20px; border-right: none; border-top: none; }
.corner-br { bottom: 120px; right: 20px; border-left: none; border-top: none; }

/* Matrix Rain */
.matrix-rain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    opacity: 0.15;
    display: none;
}

[data-theme="light"] .matrix-rain {
    display: block;
}

.matrix-flash { animation: matrixFlash 0.79s; }

@keyframes matrixFlash {
    0% { filter: brightness(1); }
    25% { filter: brightness(2); }
    50% { filter: brightness(1); }
    75% { filter: brightness(2); }
    100% { filter: brightness(1); }
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 250px;
    height: 100vh;
    background: var(--panel);
    border-right: 1px solid var(--accent);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 100;
    padding: 20px;
    overflow-y: auto;
    color: var(--text);
}

.sidebar.open { transform: translateX(0); }

.chat-item { 
    padding: 10px; 
    border-bottom: 1px solid var(--accent); 
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-item:hover { background: var(--accent-glow); }

.chat-title { flex-grow: 1; }

.chat-date { font-size: 0.8em; opacity: 0.7; }

.delete-btn { 
    background: none; 
    border: none; 
    color: #ff4444; 
    cursor: pointer; 
    padding: 0 5px;
    font-size: 0.9em;
}
.toggle-btn { 
    position: fixed; 
    left: 10px; 
    top: 10px; 
    background: var(--accent); 
    color: white; 
    border: none; 
    padding: 10px; 
    cursor: pointer; 
    z-index: 101;
    border-radius: 4px;
    font-size: 1.2em;
}

.main-content { 
    margin-left: 0; 
    transition: margin-left 0.3s ease;
    width: 100%;
}

.sidebar.open ~ .main-content { margin-left: 250px; }

.sidebar h3 {
    margin: 0 0 15px 0;
    color: var(--accent);
    text-align: center;
}

.no-chats {
    text-align: center;
    color: var(--text);
    opacity: 0.6;
    font-style: italic;
}

/* =========================================
   PERSONA MODAL & MODE SELECTOR
   ========================================= */

/* Persona Modal */
.persona-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal-content {
    text-align: center;
    max-width: 800px;
    padding: 2rem;
}

.modal-content h2 {
    color: var(--accent);
    font-size: 2rem;
    margin-bottom: 2rem;
    letter-spacing: 2px;
    text-shadow: 0 0 10px var(--accent-glow);
}

.persona-cards {
    display: flex;
    gap: 2rem;
    justify-content: center;
    flex-wrap: wrap;
    font-size: 1.1em;
}

.persona-card {
    background: rgba(255, 0, 56, 0.05);
    border: 2px solid #ff0038;
    border-radius: 12px;
    padding: 2rem;
    width: 280px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.persona-card:hover {
    background: rgba(255, 0, 56, 0.15);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(255, 0, 56, 0.3);
}

.persona-card:last-child {
    border-color: #ff00ff;
    background: rgba(255, 0, 255, 0.05);
}

.persona-card:last-child:hover {
    background: rgba(255, 0, 255, 0.15);
    box-shadow: 0 10px 30px rgba(255, 0, 255, 0.3);
}

.persona-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.persona-card h3 {
    color: var(--accent);
    font-size: 1.3em;
    margin-bottom: 0.5rem;
}

.persona-card:last-child h3 {
    color: #ff00ff;
}

/*
.persona-card p {
    color: #888;
    font-size: 0.9em;
    line-height: 1.5;
}
*/

.persona-card p {
    color: #e0e0e0;
    font-size: 0.95em;
    line-height: 1.6;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

/* Mode Selector */
.mode-selector {
    display: inline-flex;
    flex-direction: column;
    margin-right: 0.5rem;
    margin-left: 1rem;
    flex-shrink: 0;
    align-items: flex-start;
}

.mode-selector label {
    font-size: 0.65rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.2rem;
    padding-left: 0.3rem;
}

.mode-selector select {
    background: rgba(255, 0, 56, 0.1);
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 0.5rem 0.8rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
    transition: all 0.3s ease;
}

.mode-selector select:hover {
    background: rgba(255, 0, 56, 0.2);
}

.mode-selector select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
}

/* Creative mode selector styling */
[data-theme="dark"].persona-creative .mode-selector select {
    background: rgba(255, 0, 255, 0.1);
}

[data-theme="dark"].persona-creative .mode-selector select:hover {
    background: rgba(255, 0, 255, 0.2);
}

/* Mode Switch Indicator */
.mode-switch-indicator {
    text-align: center;
    color: #888;
    font-size: 0.85rem;
    padding: 0.5rem;
    margin: 1rem 0;
    opacity: 0.7;
    align-self: center;
}

/* Light theme adjustments for persona modal */
[data-theme="light"] .persona-modal {
    background: rgba(0, 0, 0, 0.98);
}

[data-theme="light"] .persona-card {
    background: rgba(0, 255, 0, 0.05);
}

[data-theme="light"] .persona-card:hover {
    background: rgba(0, 255, 0, 0.15);
}

[data-theme="light"] .persona-card:last-child {
    border-color: #00ffff;
    background: rgba(0, 255, 255, 0.05);
}

[data-theme="light"] .persona-card:last-child:hover {
    background: rgba(0, 255, 255, 0.15);
    box-shadow: 0 10px 30px rgba(0, 255, 255, 0.3);
}

[data-theme="light"] .persona-card:last-child h3 {
    color: #00ffff;
}

[data-theme="light"] .persona-card p {
    color: #aaa;
}

[data-theme="light"] .mode-selector select {
    background: rgba(0, 255, 0, 0.1);
}

[data-theme="light"] .mode-selector select:hover {
    background: rgba(0, 255, 0, 0.2);
}

[data-theme="light"] .mode-switch-indicator {
    color: #999;
}

/* === MOBILE RESPONSIVE STYLES === */
@media (max-width: 768px) {
    .persona-modal {
        display: block;
        position: fixed;
        inset: 0;
        height: 100dvh;
        overflow-y: auto;
        padding: 0;
        z-index: 10000;
        background: rgba(0, 0, 0, 0.98);
    }

    .modal-content {
        width: 100%;
        margin: 0 auto;
        box-sizing: border-box;
        /* Reduced top padding significantly to pull everything up */
        padding: 15px 1rem 120px 1rem; 
    }

    .modal-content h2 {
        margin-top: 0;
        margin-bottom: 0.8rem;   /* Tightened gap below header */
        font-size: 1.5rem;       /* Smaller header text */
    }

    .persona-cards {
        flex-direction: column;
        align-items: center;
        gap: 1rem;               /* Reduced gap between cards (was 2rem) */
        font-size: 0.95rem;      /* Slightly smaller base font */
    }

    .persona-card {
        width: 90%;
        max-width: 340px;
        padding: 1rem;           /* Compact padding (was 1.5rem) */
        box-sizing: border-box;
        margin: 0 auto;
    }

    /* Shrink the icons to save vertical space */
    .persona-icon {
        font-size: 2rem;
        margin-bottom: 0.5rem;
    }

    /* Tighten the text inside the cards */
    .persona-card h3 {
        margin-bottom: 0.3rem;
    }
    
    /* === FIX FOR MESSAGE BAR CLIPPING === */
    .input-container {
        padding: 10px;           /* Gained width by reducing padding */
    }

    .input-area {
        border-radius: 20px;     /* Sharper corners prevent clipping the dropdown */
    }

    .mode-selector {
        margin-left: 0.2rem;
        margin-bottom: 6px;      /* Aligns with the bottom of the textarea */
    }

    .mode-selector select {
        padding: 0.3rem;         /* Tighter padding */
        font-size: 0.8rem;       /* Slightly smaller text to prevent overflow */
        max-width: 90px;         /* Ensures it never pushes the input out */
    }

    #message-input {
        padding: 0.8rem 0.5rem;  /* Tighter padding for mobile */
        font-size: 0.95rem;      /* Prevent zoom on focus for iOS */
    }

    #send-button {
        padding: 0 1rem;
        height: 100%;            /* Ensures button covers height */
        min-height: 45px;        /* Minimum touch target */
    }
}

/* =========================================
   AUTH & FORM STYLES (login.php / signup.php)
   ========================================= */

.form-container {
    max-width: 400px;
    margin: 50px auto;
    padding: 20px;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--accent);
    text-align: left;
}

.form-container h2 {
    margin-top: 0;
}

.form-container label {
    display: block;
    margin-bottom: 5px;
}

.form-container input {
    width: 100%;
    padding: 8px;
    margin-bottom: 15px;
    box-sizing: border-box;
    border: 1px solid #333;
    background: #1a1a1a;
    color: #e0e0e0;
}

.form-container input:focus {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.form-container input[aria-invalid="true"] {
    border: 2px solid red;
}

.form-container input[aria-invalid="true"]:focus {
    outline: 3px solid red;
}

.form-container button {
    padding: 10px 20px;
    border: none;
    cursor: pointer;
    background: var(--accent);
    color: white;
}

.form-container button:focus {
    outline: 3px solid white;
    outline-offset: 2px;
}

.error {
    color: red;
    margin-bottom: 15px;
}

.error:focus {
    outline: 2px solid red;
    outline-offset: 2px;
}

.success {
    color: #00ff00;
    margin-bottom: 15px;
}

.success:focus {
    outline: 2px solid #00ff00;
    outline-offset: 2px;
}

.login-link {
    margin-top: 15px;
    text-align: center;
}

.login-link a {
    color: var(--accent);
    text-decoration: none;
}

.login-link a:hover {
    text-decoration: underline;
}

.login-link a:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Password Strength Meter */
.password-strength {
    margin-top: -10px;
    margin-bottom: 15px;
}

.password-strength-bar {
    height: 5px;
    background: #333;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 5px;
}

.password-strength-fill {
    height: 100%;
    width: 0%;
    transition: all 0.3s ease;
}

.password-strength-fill.score-0 { width: 20%; background: #d32f2f; }
.password-strength-fill.score-1 { width: 40%; background: #f57c00; }
.password-strength-fill.score-2 { width: 60%; background: #fbc02d; }
.password-strength-fill.score-3 { width: 80%; background: #689f38; }
.password-strength-fill.score-4 { width: 100%; background: #388e3c; }

.password-strength-text {
    font-size: 0.9em;
    color: #999;
}

/* Google Button */
.google-button {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 15px;
    background-color: #424242;
    color: #ffffff;
    border-radius: 30px;
    text-decoration: none;
    font-family: 'Rajdhani', sans-serif;
    font-size: 1em;
    font-weight: bold;
    letter-spacing: 0.1rem;
    border: 1px solid #424242;
    transition: background-color 0.2s;
    cursor: pointer;
    margin-bottom: 15px;
}

.google-button:hover,
.google-button:focus {
    background-color: #505050;
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.google-button .google-logo {
    width: 18px;
    height: 18px;
    margin-right: 10px;
}

/* Microsoft Button */
.microsoft-button {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 15px;
    background-color: #424242;
    color: #ffffff;
    border-radius: 30px;
    text-decoration: none;
    font-family: 'Rajdhani', sans-serif;
    font-size: 1em;
    font-weight: bold;
    letter-spacing: 0.1rem;
    border: 1px solid #424242;
    transition: background-color 0.2s;
    cursor: pointer;
    margin-bottom: 20px;
}

.microsoft-button:hover,
.microsoft-button:focus {
    background-color: #505050;
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.microsoft-button .microsoft-logo {
    width: 18px;
    height: 18px;
    margin-right: 10px;
}

/* Divider OR */
.divider-or {
    display: flex;
    align-items: center;
    text-align: center;
    color: #999;
    margin-bottom: 20px;
}

.divider-or::before,
.divider-or::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #333;
}

.divider-or:not(:empty)::before { margin-right: .5em; }
.divider-or:not(:empty)::after { margin-left: .5em; }

/* =========================================
   FAQ PAGE STYLES (faq.html)
   ========================================= */

/* FAQ page needs scrolling enabled - override default body behavior */
body.faq-page {
    overflow-y: auto;
    height: auto;
}

body.faq-page .main-wrapper {
    height: auto;
    overflow: visible;
}

.faq-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
    padding-bottom: 4rem;
    color: var(--text);
}

.faq-header {
    text-align: center;
    margin-bottom: 3rem;
}

.faq-header h1 {
    color: var(--accent);
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: 0.2rem;
    text-transform: uppercase;
    text-shadow: 0 0 10px var(--accent-glow);
    margin-bottom: 1rem;
}

.faq-intro {
    font-size: 1.1rem;
    line-height: 1.8;
    opacity: 0.9;
    margin-bottom: 1rem;
}

.faq-section {
    margin-bottom: 3rem;
}

.faq-section-title {
    color: var(--accent);
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 0.15rem;
    text-transform: uppercase;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent);
    text-shadow: 0 0 8px var(--accent-glow);
}

.faq-item {
    background: var(--panel);
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.faq-item:hover {
    box-shadow: 0 4px 16px var(--accent-glow);
    transform: translateY(-2px);
}

.faq-question {
    color: var(--accent);
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    letter-spacing: 0.05rem;
}

.faq-answer {
    line-height: 1.8;
    opacity: 0.9;
}

.faq-answer ul {
    margin: 1rem 0;
    padding-left: 2rem;
}

.faq-answer li {
    margin-bottom: 0.8rem;
    line-height: 1.6;
}

.faq-answer strong {
    color: var(--accent);
    font-weight: 700;
}

.warning-box {
    background: rgba(255, 0, 56, 0.1);
    border: 2px solid var(--accent);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1rem 0;
}

.warning-box strong {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.back-link {
    text-align: center;
    margin: 3rem 0 2rem;
}

.back-link a {
    display: inline-block;
    padding: 1rem 2rem;
    background: var(--accent);
    color: white;
    text-decoration: none;
    border-radius: 50px;
    font-weight: 700;
    letter-spacing: 0.1rem;
    text-transform: uppercase;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px var(--accent-glow);
}

.back-link a:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 25px var(--accent-glow);
}

[data-theme="light"] .back-link a {
    color: #000;
}

@media (max-width: 768px) {
    .faq-container {
        padding: 1rem;
    }

    .faq-header h1 {
        font-size: 1.8rem;
    }

    .faq-section-title {
        font-size: 1.3rem;
    }

    .faq-question {
        font-size: 1.1rem;
    }

    .faq-item {
        padding: 1rem;
    }
}