/* ===== SafeSpace AI - Production CSS ===== */

/* Root variables for theming */
:root {
    /* Light mode colors */
    --bg-primary: #fafbff;
    --bg-secondary: #f5f7fc;
    --bg-accent: #efefff;
    --text-primary: #2c3e50;
    --text-secondary: #667588;
    --border-color: #e8ebf5;
    
    /* Brand colors - soft pastels */
    --color-ai: #f0e6ff;
    --color-user: #ffe6f0;
    --color-accent-1: #c8d8f0;
    --color-accent-2: #ffd6e0;
    --color-accent-3: #e6f5ff;
    
    /* Interactive colors */
    --color-success: #6ec5b4;
    --color-warning: #f5a962;
    --color-error: #e8746b;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark mode */
html[data-theme="dark"] {
    --bg-primary: #0f1419;
    --bg-secondary: #1a1f2e;
    --bg-accent: #242d42;
    --text-primary: #e8eef5;
    --text-secondary: #a0aab8;
    --border-color: #2a333f;
    
    --color-ai: #2a1d4a;
    --color-user: #3d1a2f;
    --color-accent-1: #1a2647;
    --color-accent-2: #2d1a24;
    --color-accent-3: #1a2d42;
}

/* ===== Global Styles ===== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: var(--transition);
    overflow: hidden;
    height: 100vh;
}

/* ===== Animated Background ===== */

.background-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}

.floating-shape {
    position: absolute;
    border-radius: 50%;
    opacity: 0.15;
    filter: blur(60px);
    animation: float 20s infinite ease-in-out;
}

.shape-1 {
    width: 300px;
    height: 300px;
    background: linear-gradient(135deg, #ffc0de, #c8d8f0);
    top: -10%;
    left: -5%;
    animation-delay: 0s;
}

.shape-2 {
    width: 250px;
    height: 250px;
    background: linear-gradient(135deg, #c8d8f0, #e6f5ff);
    top: 30%;
    right: -5%;
    animation-delay: 5s;
}

.shape-3 {
    width: 200px;
    height: 200px;
    background: linear-gradient(135deg, #e6f5ff, #ffc0de);
    bottom: 20%;
    left: 10%;
    animation-delay: 10s;
}

.shape-4 {
    width: 280px;
    height: 280px;
    background: linear-gradient(135deg, #fff0f5, #f0e6ff);
    bottom: -10%;
    right: 5%;
    animation-delay: 15s;
}

@keyframes float {
    0%, 100% { transform: translateY(0px) translateX(0px); }
    25% { transform: translateY(-30px) translateX(20px); }
    50% { transform: translateY(30px) translateX(-20px); }
    75% { transform: translateY(-10px) translateX(10px); }
}

/* ===== Main Container ===== */

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 900px;
    margin: 0 auto;
    background: rgba(250, 251, 255, 0.8);
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 1;
}

html[data-theme="dark"] .container {
    background: rgba(15, 20, 25, 0.8);
}

/* ===== Header ===== */

.header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content {
    flex: 1;
}

.title {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0 0 0.25rem 0;
    background: linear-gradient(135deg, #c8a2e0, #ffa8d3);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0;
}

.header-controls {
    display: flex;
    gap: 0.5rem;
}

.control-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--bg-accent);
    border-radius: var(--radius-full);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    background: var(--color-accent-1);
    transform: scale(1.05);
}

.control-btn:active {
    transform: scale(0.95);
}

/* ===== Chat Area ===== */

.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.welcome-message {
    text-align: center;
    padding: 2rem;
    margin: auto;
    opacity: 0;
    animation: fadeInUp 0.6s ease-out 0.2s forwards;
}

.welcome-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    display: inline-block;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.welcome-message h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.welcome-message p {
    color: var(--text-secondary);
    margin: 0.5rem 0;
    line-height: 1.6;
}

.welcome-subtitle {
    font-size: 0.9rem !important;
}

/* ===== Messages ===== */

.message {
    max-width: 80%;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-lg);
    word-wrap: break-word;
    line-height: 1.5;
    animation: fadeInUp 0.4s ease-out;
    box-shadow: var(--shadow-sm);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    background: linear-gradient(135deg, var(--color-user), rgba(255, 214, 224, 0.6));
    margin-left: auto;
    border-bottom-right-radius: 8px;
    color: var(--text-primary);
    font-weight: 500;
}

.message.ai {
    background: linear-gradient(135deg, var(--color-ai), rgba(200, 216, 240, 0.3));
    margin-right: auto;
    border-bottom-left-radius: 8px;
    color: var(--text-primary);
}

html[data-theme="dark"] .message.ai {
    background: linear-gradient(135deg, var(--color-ai), rgba(42, 29, 74, 0.5));
}

html[data-theme="dark"] .message.user {
    background: linear-gradient(135deg, var(--color-user), rgba(61, 26, 47, 0.5));
}

/* Typing animation */
.message.typing::after {
    content: '';
    animation: typing 1.4s infinite;
}

@keyframes typing {
    0% { content: ''; }
    25% { content: '●'; }
    50% { content: '●●'; }
    75% { content: '●●●'; }
    100% { content: ''; }
}

/* ===== Thinking Indicator ===== */

.thinking-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.5rem 0;
    opacity: 1;
    animation: fadeIn 0.3s ease-out;
}

.thinking-indicator.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.thinking-dots {
    display: flex;
    gap: 0.3rem;
}

.thinking-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: dot-bounce 1.4s infinite;
}

.thinking-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.thinking-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dot-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

.thinking-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* ===== Input Area ===== */

.input-container {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.message-input-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-wrapper {
    display: flex;
    gap: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 0.75rem;
    transition: var(--transition);
    align-items: flex-end;
}

.input-wrapper:focus-within {
    border-color: var(--color-accent-1);
    box-shadow: var(--shadow-md);
}

#messageInput {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-primary);
    resize: none;
    max-height: 120px;
    padding: 0.25rem 0;
}

#messageInput::placeholder {
    color: var(--text-secondary);
}

.send-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: linear-gradient(135deg, #c8a2e0, #ffa8d3);
    border-radius: var(--radius-full);
    color: white;
    cursor: pointer;
    font-size: 1.2rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.send-btn:hover {
    transform: scale(1.08);
    box-shadow: var(--shadow-md);
}

.send-btn:active {
    transform: scale(0.95);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-icon {
    display: inline-block;
}

.input-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 0;
    opacity: 0.7;
}

/* ===== Action Buttons ===== */

.action-buttons {
    display: flex;
    gap: 0.75rem;
    padding: 0 1.5rem 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.action-btn {
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-accent);
    color: var(--text-primary);
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.affirmation-btn {
    border-left: 3px solid #ffa8d3;
}

.breathing-btn {
    border-left: 3px solid #a8d3ff;
}

.resources-btn {
    border-left: 3px solid #d3a8ff;
}

/* ===== Modal Styles ===== */

.modal {
    display: flex;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease-out;
    position: relative;
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
    transform: scale(1.2);
}

.modal-content h2 {
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #c8a2e0, #ffa8d3);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.breathing-instruction {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* Breathing Exercise Styles */
.breath-circle {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-accent-1), var(--color-accent-2));
    margin: 2rem auto;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    animation: breathe 8s infinite;
    box-shadow: var(--shadow-md);
}

@keyframes breathe {
    0% { transform: scale(1); }
    25% { transform: scale(1.3); }
    50% { transform: scale(1); }
    75% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.breath-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.breath-count {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 0.5rem;
}

.breathing-guide {
    margin: 1.5rem 0;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--color-accent-1);
}

.breathing-guide p {
    margin: 0.75rem 0;
    color: var(--text-primary);
    font-size: 0.95rem;
}

/* Resources Modal */
.resource-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.resource-section:last-child {
    border-bottom: none;
}

.resource-section h3 {
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    font-size: 1.05rem;
}

.resource-section ul {
    list-style: none;
    padding: 0;
}

.resource-section li {
    padding: 0.5rem 0;
    color: var(--text-secondary);
    line-height: 1.6;
    padding-left: 1.5rem;
    position: relative;
}

.resource-section li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--color-accent-1);
}

.modal-btn {
    width: 100%;
    padding: 0.75rem 1.5rem;
    margin-top: 1rem;
    background: linear-gradient(135deg, #c8a2e0, #ffa8d3);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.modal-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ===== Responsive Design ===== */

@media (max-width: 768px) {
    .title {
        font-size: 1.4rem;
    }

    .message {
        max-width: 90%;
        padding: 0.75rem 1rem;
    }

    .action-buttons {
        padding: 0 1rem 1rem;
        gap: 0.5rem;
    }

    .action-btn {
        font-size: 0.8rem;
        padding: 0.65rem 1rem;
        flex: 1;
        min-width: auto;
    }

    .chat-area {
        padding: 1rem;
    }

    .modal-content {
        padding: 1.5rem;
        max-height: 90vh;
    }

    .breath-circle {
        width: 150px;
        height: 150px;
    }

    .breath-count {
        font-size: 2rem;
    }

    .header {
        padding: 1rem;
    }

    .input-container {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .title {
        font-size: 1.2rem;
    }

    .subtitle {
        font-size: 0.75rem;
    }

    .message {
        max-width: 95%;
    }

    .action-buttons {
        flex-direction: column;
        padding: 0 0.75rem 1rem;
    }

    .action-btn {
        width: 100%;
    }

    .control-btn {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .welcome-icon {
        font-size: 3rem;
    }

    .modal-content {
        width: 95%;
        padding: 1.25rem;
        border-radius: var(--radius-md);
    }

    .modal-close {
        top: 0.75rem;
        right: 0.75rem;
    }
}

/* ===== Scrollbar Styling ===== */

.chat-area::-webkit-scrollbar {
    width: 8px;
}

.chat-area::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
}

.chat-area::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
    transition: var(--transition);
}

.chat-area::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Firefox */
.chat-area {
    scrollbar-color: var(--border-color) var(--bg-secondary);
    scrollbar-width: thin;
}

/* ===== Accessibility ===== */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (prefers-color-scheme: dark) {
    html {
        color-scheme: dark;
    }
}