:root {
    --ios-blue: #007AFF;
    --ios-gray: #E9E9EB;
    /* Received bubble */
    --ios-green: #34C759;
    --ios-bg: #FFFFFF;
    --ios-text-dark: #000000;
    --ios-text-light: #FFFFFF;
    --ios-border: #C6C6C8;
    --unsa-red: #e2001a;
    /* Kept for branding accents only */
    --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    font-family: var(--font-stack);
    background-color: #f2f2f7;
    /* Fallback */
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    /* Dynamic Gradient Background */
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    position: relative;
    overflow: hidden;
}

/* Add a subtle mesh gradient overlay */
body::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(226, 0, 26, 0.05), transparent 60%),
        radial-gradient(circle at 80% 20%, rgba(0, 122, 255, 0.05), transparent 50%);
    animation: rotate 20s linear infinite;
    z-index: -1;
}

@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Main Container - Enhanced Glassmorphism & Entrance */
.chat-container.glass {
    width: 100%;
    max-width: 500px;
    height: 100vh;
    max-height: 800px;
    background: rgba(255, 255, 255, 0.7);
    /* More transparent for glass effect */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1), 0 5px 15px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.5);
    /* Lighter, "glassy" border */
    position: relative;
    animation: containerPop 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    transform-origin: center center;
}

@keyframes containerPop {
    0% {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }

    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@media (max-width: 600px) {
    .chat-container.glass {
        border-radius: 0;
        height: 100%;
        max-height: 100%;
        border: none;
    }
}

/* Header - Modern App Header */
.chat-header {
    background: rgba(255, 255, 255, 0.85);
    /* Slightly more transparent */
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    padding: 15px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    z-index: 10;
    cursor: pointer;
    user-select: none;
    transition: background 0.3s;
}

.chat-header:hover {
    background: rgba(255, 255, 255, 0.95);
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.header-content h1 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--ios-text-dark);
}

.header-content .subtitle {
    margin: 2px 0 0 0;
    font-size: 12px;
    color: #34C759;
    /* Green for "Online" status */
    font-weight: 500;
}

/* Chat Area */
.chat-messages {
    flex: 1;
    padding: 20px 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: transparent;
    /* Let body bg shine through if transparent */
}

/* Bubbles - Slide In Animation */
.message {
    max-width: 80%;
    padding: 12px 16px;
    font-size: 16px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    opacity: 0;
    /* Updated by animation */
    animation: messageSlideIn 0.4s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes messageSlideIn {
    0% {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Bot (Received) - Gray */
.message.bot {
    align-self: flex-start;
    background-color: #f2f2f7;
    color: var(--ios-text-dark);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
}

/* User (Sent) - Blue */
.message.user {
    align-self: flex-end;
    background-color: var(--ios-blue);
    color: var(--ios-text-light);
    border-radius: 18px;
    border-bottom-right-radius: 4px;
}

/* Input Area - Clean Style */
.chat-input-area {
    padding: 15px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 12px;
}

#user-input {
    flex: 1;
    padding: 12px 20px;
    border: 1px solid #E5E5EA;
    border-radius: 24px;
    font-size: 16px;
    font-family: var(--font-stack);
    outline: none;
    -webkit-appearance: none;
    background-color: #f2f2f7;
    transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
}

#user-input:focus {
    background-color: #fff;
    border-color: var(--ios-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
    /* Glow effect */
    transform: scale(1.01);
}

#send-btn {
    background: transparent;
    color: var(--ios-blue);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    /* Bouncy */
}

#send-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
    margin-left: 2px;
    transition: transform 0.2s;
}

#send-btn:hover {
    background-color: rgba(0, 122, 255, 0.05);
    transform: scale(1.1);
}

#send-btn:active {
    transform: scale(0.95);
}

/* Sending Animation Class (to be added by JS optionally) */
.sending svg {
    animation: flyAway 0.5s ease-in forwards;
}

@keyframes flyAway {
    0% {
        transform: translateX(0) translateY(0);
        opacity: 1;
    }

    100% {
        transform: translateX(20px) translateY(-20px);
        opacity: 0;
    }
}

/* Typing Indicator */
.typing-indicator-bubble {
    align-self: flex-start;
    background-color: #f2f2f7;
    padding: 12px 18px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    display: none;
    /* Hidden by default */
    width: fit-content;
    margin-bottom: 5px;
    animation: messageSlideIn 0.3s ease-out forwards;
}

.dot {
    width: 8px;
    height: 8px;
    background-color: #8E8E93;
    border-radius: 50%;
    display: inline-block;
    animation: dotPulse 1.4s infinite ease-in-out both;
    margin: 0 2px;
}

@keyframes dotPulse {

    0%,
    80%,
    100% {
        transform: scale(0);
        opacity: 0.6;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.dot:nth-child(1) {
    animation-delay: -0.32s;
}

.dot:nth-child(2) {
    animation-delay: -0.16s;
}

/* Admin Modal */
.admin-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    /* Hidden by default */
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(5px);
}

.admin-content {
    background: #fff;
    width: 85%;
    max-height: 80%;
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.admin-content h2 {
    margin-top: 0;
    font-size: 18px;
    text-align: center;
}

#admin-login-view,
#admin-editor-view {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

textarea#prompt-editor {
    width: 100%;
    height: 300px;
    font-family: monospace;
    font-size: 12px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 8px;
    resize: vertical;
}

.admin-btn {
    padding: 10px;
    border-radius: 8px;
    border: none;
    font-size: 16px;
    cursor: pointer;
    font-weight: 600;
}

.btn-primary {
    background: var(--ios-blue);
    color: white;
}

.btn-secondary {
    background: #E9E9EB;
    color: black;
}

.error-msg {
    color: red;
    font-size: 12px;
    text-align: center;
    display: none;
}