/* Global Styles */
:root {
    --vh: 1vh;
}

.logo-container {
    margin-bottom: 3rem;
    position: relative;
}

/* .logo-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, var(--glow) 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: pulse 3s ease-in-out infinite;
} */

.logo {
    width: 200px;
    height: 200px;
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 8px 32px var(--glow));
    object-fit: contain; 
    border-radius: 50%; 
}

/* اگر نمی‌خواهید لوگو بچرخد، این خط را حذف کنید */
@keyframes logoRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* برای موبایل */
@media (max-width: 768px) {
    .logo {
        width: 160px;
        height: 160px;
    }
    
    .logo-glow {
        width: 150px;
        height: 150px;
    }
}

/* Splash Content */
.splash-content {
    text-align: center;
    color: white;
    padding: 2rem;
    position: relative;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100%;
}

/* Icons Grid 2x2 */
.animated-icons {
    display: flex;
    flex-direction: column;
    gap: 80px;
    margin-bottom: 60px;
}

.icon-row {
    display: flex;
    gap: 120px;
    justify-content: center;
    align-items: center;
}

.icon-wrapper {
    position: relative;
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: float 4s ease-in-out infinite;
}

.icon-wrapper:nth-child(1) { animation-delay: 0s; }
.icon-wrapper:nth-child(2) { animation-delay: 1s; }

.icon-row:nth-child(2) .icon-wrapper:nth-child(1) { animation-delay: 2s; }
.icon-row:nth-child(2) .icon-wrapper:nth-child(2) { animation-delay: 3s; }

.icon-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 90px;
    height: 90px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 60%);
    transform: translate(-50%, -50%);
    animation: pulse 2s ease-in-out infinite;
    border-radius: 50%;
}

.icon {
    width: 50px;
    height: 50px;
    color: white;
    opacity: 0.9;
    position: relative;
    z-index: 1;
}

/* Title and Subtitle */
.splash-title {
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
    opacity: 1;
    letter-spacing: -0.02em;
}

.splash-subtitle {
    font-size: 1rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.6;
    margin: 0;
}

/* Powered by - Remove if not needed */
.powered-by {
    display: none;
}

/* Animations */
@keyframes float {
    0%, 100% { 
        transform: translateY(0) scale(1); 
    }
    50% { 
        transform: translateY(-8px) scale(1.05); 
    }
}

@keyframes pulse {
    0%, 100% { 
        transform: translate(-50%, -50%) scale(1); 
        opacity: 0.1;
    }
    50% { 
        transform: translate(-50%, -50%) scale(1.2); 
        opacity: 0.2;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .icon-row {
        gap: 40px;
    }
    
    .animated-icons {
        gap: 60px;
    }
    
    /* .icon-wrapper {
        width: 60px;
        height: 60px;
    }
    
    .icon {
        width: 35px;
        height: 35px;
    } */
    
    .splash-title {
        font-size: 1.75rem;
    }
    
    .splash-subtitle {
        font-size: 0.875rem;
    }
}

/* Dark Theme Variables */
body.dark-theme {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #60a5fa;
    --secondary: #10b981;
    --secondary-light: #34d399;
    --background: #0a0e1a;
    --surface: #1a1f2e;
    --surface-light: #252b3b;
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --border: #2d3748;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.7);
    --glow: rgba(59, 130, 246, 0.5);
}

/* Light Theme Variables */
body.light-theme {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #3b82f6;
    --secondary: #059669;
    --secondary-light: #10b981;
    --background: #f9fafb;
    --surface: #ffffff;
    --surface-light: #f3f4f6;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.16);
    --glow: rgba(37, 99, 235, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    direction: rtl;
    overflow: hidden;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    position: fixed;
    width: 100%;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Prevent iOS bounce */
body {
    overscroll-behavior: none;
}

/* Screen Management */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: calc(var(--vh, 1vh) * 100);
    display: none;
    background: var(--background);
    z-index: 1;
    overflow: hidden;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* Splash Screen - Dark background to match theme */
#splash-screen {
    align-items: center;
    justify-content: center;
    background: var(--background);
    z-index: 1000;
}

.splash-video {
    position: absolute;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    transform: translate(-50%, -50%);
    z-index: 1;
    object-fit: cover;
}

.splash-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        135deg,
        rgba(59, 130, 246, 0.3) 0%,
        rgba(139, 92, 246, 0.3) 100%
    );
    z-index: 2;
}

.splash-content {
    text-align: center;
    color: white;
    padding: 2rem;
    position: relative;
    z-index: 3;
}

.animated-icons {
    position: relative;
    height: 250px;
    margin-bottom: 3rem;
}

.icon-wrapper {
    position: absolute;
    animation: float 4s ease-in-out infinite;
}

.icon-wrapper.icon-1 {
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    animation-delay: 0s;
    --tx: -50%;
}

.icon-wrapper.icon-2 {
    top: 80px;
    left: 15%;
    transform: translateX(0);
    animation-delay: 1s;
    --tx: 0;
}

.icon-wrapper.icon-3 {
    top: 80px;
    right: 15%;
    transform: translateX(0);
    animation-delay: 2s;
    --tx: 0;
}

.icon-wrapper.icon-4 {
    top: 150px;
    left: 50%;
    transform: translateX(-50%);
    animation-delay: 3s;
    --tx: -50%;
}

.icon-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80px;
    height: 80px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: pulse 2s ease-in-out infinite;
}

.icon-wrapper .icon {
    width: 64px;
    height: 64px;
    color: white;
    opacity: 0;
    filter: drop-shadow(0 4px 20px rgba(255, 255, 255, 0.5));
    animation: fadeInScale 0.8s ease-out forwards;
    position: relative;
    z-index: 1;
}

.icon-wrapper.icon-1 .icon { animation-delay: 0.5s; }
.icon-wrapper.icon-2 .icon { animation-delay: 1s; }
.icon-wrapper.icon-3 .icon { animation-delay: 1.5s; }
.icon-wrapper.icon-4 .icon { animation-delay: 2s; }

@keyframes float {
    0%, 100% { 
        transform: translateY(0) translateX(var(--tx)); 
    }
    50% { 
        transform: translateY(-15px) translateX(var(--tx)); 
    }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.3) rotate(-180deg);
    }
    to {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

@keyframes pulse {
    0%, 100% { 
        transform: translate(-50%, -50%) scale(1); 
        opacity: 0.5;
    }
    50% { 
        transform: translate(-50%, -50%) scale(1.5); 
        opacity: 0.2;
    }
}

.splash-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 2rem;
    opacity: 0;
    animation: fadeInUp 1s ease-out 2.5s forwards;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    letter-spacing: -0.02em;
}

.loading-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    opacity: 0;
    animation: fadeIn 0.5s ease-out 3s forwards;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    animation: loadingDot 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes loadingDot {
    0%, 80%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    40% {
        transform: scale(1.5);
        opacity: 0.5;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Welcome Screen */
#welcome-screen {
    align-items: center;
    justify-content: center;
    background: var(--background);
}

.welcome-content {
    width: 100%;
    max-width: 420px;
    padding: 2rem;
    text-align: center;
    animation: fadeIn 0.5s ease-out;
}

.logo-container {
    margin-bottom: 3rem;
    position: relative;
}

.logo-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, var(--glow) 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: pulse 3s ease-in-out infinite;
}


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

.welcome-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    letter-spacing: -0.02em;
}

.welcome-subtitle {
    color: var(--text-secondary);
    margin-bottom: 3rem;
    font-size: 1.125rem;
}

.button-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.primary-button,
.secondary-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.25rem 2rem;
    border: none;
    border-radius: 16px;
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
    position: relative;
    overflow: hidden;
}

.button-shine {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.2) 50%,
        transparent 100%
    );
    transition: left 0.5s ease;
}

.primary-button:hover .button-shine,
.secondary-button:hover .button-shine {
    left: 100%;
}

.primary-button {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
}

.primary-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(59, 130, 246, 0.6);
}

.secondary-button {
    background: var(--surface);
    color: var(--primary);
    border: 2px solid var(--primary);
}

.secondary-button:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(59, 130, 246, 0.6);
}

.button-icon {
    width: 24px;
    height: 24px;
}

/* Admin Link - Initially Hidden */
.admin-link {
    margin-top: 3rem;
    padding: 0.75rem 1.5rem;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    align-items: center;
    gap: 0.5rem;
}

.admin-link:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

.admin-link svg {
    width: 16px;
    height: 16px;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    padding: 2rem;
    border-radius: 20px;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-xl);
    animation: modalSlide 0.3s ease-out;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--surface-light);
    color: var(--text-primary);
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    text-align: center;
    color: var(--text-primary);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-group {
    position: relative;
}

.input-group svg {
    position: absolute;
    top: 50%;
    right: 1rem;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
}

.input-group input {
    width: 100%;
    padding: 1rem 3rem 1rem 1rem;
    background: var(--background);
    border: 2px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.2s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--surface-light);
}

.login-button {
    padding: 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.login-button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

/* Chat Screen - Enhanced */
#chat-screen {
    background: var(--background);
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    display: flex;
    flex-direction: column;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0.75rem;
    padding-top: calc(1rem + env(safe-area-inset-top, 0px));
    background: var(--surface);
    color: var(--text-primary);
    box-shadow: var(--shadow);
    min-height: 60px;
    flex-shrink: 0;
}

.back-button {
    background: transparent;
    border: none;
    color: var(--primary);
    cursor: pointer;
    padding: 0.75rem;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-button:hover {
    background: rgba(59, 130, 246, 0.1);
    transform: scale(1.1);
}

.back-button svg {
    width: 24px;
    height: 24px;
}

.chat-title {
    flex: 1;
    font-size: 1.125rem;
    font-weight: 600;
    text-align: center;
    margin: 0;
    padding: 0 1rem;
}

/* Theme Toggle Button */
.theme-toggle {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.75rem;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 40px;
    height: 40px;
}

.theme-toggle:hover {
    background: var(--surface-light);
    transform: scale(1.1);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    position: absolute;
    transition: all 0.3s ease;
}

body.dark-theme .sun-icon {
    opacity: 0;
    transform: rotate(180deg) scale(0);
}

body.dark-theme .moon-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

body.light-theme .sun-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

body.light-theme .moon-icon {
    opacity: 0;
    transform: rotate(180deg) scale(0);
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: var(--background);
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Custom Scrollbar */
.messages-container::-webkit-scrollbar {
    width: 8px;
}

.messages-container::-webkit-scrollbar-track {
    background: var(--surface);
    border-radius: 4px;
}

.messages-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.message {
    display: flex;
    margin-bottom: 1.5rem;
    animation: messageSlide 0.3s ease-out;
    align-items: flex-end;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    flex-direction: row;
}

.message.assistant {
    flex-direction: row-reverse;
}

.message-bubble {
    max-width: 75%;
    padding: 1rem 1.25rem;
    border-radius: 20px;
    word-wrap: break-word;
    position: relative;
    font-size: 0.9375rem;
    line-height: 1.6;
    box-shadow: var(--shadow);
}

.message.user .message-bubble {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border-bottom-right-radius: 4px;
    margin-left: 8px;
}

.message.assistant .message-bubble {
    background: var(--surface);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    margin-right: 8px;
    border: 1px solid var(--border);
}

/* HTML Content Styles for Assistant Messages */
.message.assistant .message-bubble h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 1rem 0 0.5rem 0;
    color: var(--primary);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.25rem;
}

.message.assistant .message-bubble h2:first-child {
    margin-top: 0;
}

.message.assistant .message-bubble h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0.75rem 0 0.4rem 0;
    color: var(--text-primary);
}

.message.assistant .message-bubble h3:first-child {
    margin-top: 0;
}

/* Beautiful Section Styling */
.message.assistant .message-bubble .section-wrapper {
    margin: 0.5rem 0;
    padding: 0.75rem 0;
}

.message.assistant .message-bubble .section-wrapper:first-child {
    padding-top: 0;
}

.message.assistant .message-bubble .section-heading {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
    color: var(--primary);
    position: relative;
    padding-right: 1rem;
}

.message.assistant .message-bubble .section-heading::before {
    content: "◈";
    position: absolute;
    right: 0;
    color: var(--primary);
    opacity: 0.6;
}

/* Beautiful Divider Line */
.message.assistant .message-bubble .section-divider {
    margin: 1.5rem 0;
    height: 1px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        var(--primary) 20%, 
        var(--primary) 50%, 
        var(--primary) 80%, 
        transparent 100%);
    opacity: 0.3;
    position: relative;
}

.message.assistant .message-bubble .section-divider::before {
    content: "❋";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--surface);
    color: var(--primary);
    padding: 0 0.5rem;
    font-size: 0.8rem;
    opacity: 0.5;
}

/* Alternative divider styles - uncomment to use */
/* Style 2: Dotted line with diamond */
/*
.message.assistant .message-bubble .section-divider {
    margin: 1.5rem 0;
    height: 20px;
    background-image: radial-gradient(circle, var(--primary) 1px, transparent 1px);
    background-size: 10px 10px;
    background-position: center center;
    opacity: 0.2;
}
*/

/* Style 3: Gradient fade */
/*
.message.assistant .message-bubble .section-divider {
    margin: 1.5rem 0;
    height: 2px;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(var(--primary-rgb), 0.2) 25%, 
        rgba(var(--primary-rgb), 0.4) 50%, 
        rgba(var(--primary-rgb), 0.2) 75%, 
        transparent);
    border-radius: 2px;
}
*/

.message.assistant .message-bubble p {
    margin: 0.5rem 0;
    line-height: 1.7;
}

.message.assistant .message-bubble p:first-child {
    margin-top: 0;
}

.message.assistant .message-bubble p:last-child {
    margin-bottom: 0;
}

.message.assistant .message-bubble ul,
.message.assistant .message-bubble ol {
    margin: 0.75rem 0;
    padding-right: 1.5rem;
    padding-left: 0;
}

.message.assistant .message-bubble ul:first-child,
.message.assistant .message-bubble ol:first-child {
    margin-top: 0;
}

.message.assistant .message-bubble ul:last-child,
.message.assistant .message-bubble ol:last-child {
    margin-bottom: 0;
}

.message.assistant .message-bubble li {
    margin: 0.4rem 0;
    line-height: 1.6;
}

.message.assistant .message-bubble ul li {
    list-style-type: disc;
}

.message.assistant .message-bubble ol li {
    list-style-type: decimal;
}

.message.assistant .message-bubble strong {
    font-weight: 600;
    color: var(--primary);
}

/* Light theme adjustments for HTML content */
.light-theme .message.assistant .message-bubble h2 {
    color: var(--primary);
    border-bottom-color: rgba(0, 0, 0, 0.1);
}

.light-theme .message.assistant .message-bubble h3 {
    color: var(--text-primary);
}

.light-theme .message.assistant .message-bubble strong {
    color: var(--primary-dark);
}

.light-theme .message.assistant .message-bubble .section-divider {
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(0, 0, 0, 0.2) 20%, 
        rgba(0, 0, 0, 0.3) 50%, 
        rgba(0, 0, 0, 0.2) 80%, 
        transparent 100%);
}

.light-theme .message.assistant .message-bubble .section-divider::before {
    background: white;
    color: var(--primary);
}

.message-time {
    font-size: 0.625rem;
    color: var(--text-secondary);
    margin: 0 12px;
    white-space: nowrap;
}

/* Audio Play Button - Enhanced */
.message-audio-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 8px 20px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 24px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    backdrop-filter: blur(10px);
}

.message.assistant .message-audio-btn {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
    border-color: var(--primary);
}

.message-audio-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.message.assistant .message-audio-btn:hover {
    background: var(--primary);
    color: white;
}

.message-audio-btn.playing {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    animation: pulse 1.5s infinite;
}

.message-audio-btn.playing:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: scale(1.05);
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}

.message-audio-btn svg {
    width: 16px;
    height: 16px;
}

.message-audio-btn svg.spinning {
    animation: spin 1s linear infinite;
}

/* Modern Input Container */
.input-container {
    padding: 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    background: var(--surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
}

.message-input-container {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--surface-light);
    border-radius: 24px;
    padding: 0.75rem 1.25rem;
    transition: all 0.2s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.message-input-container:focus-within {
    background: var(--background);
    box-shadow: 0 0 0 2px var(--primary), inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.message-input {
    flex: 1;
    background: none;
    border: none;
    padding: 0;
    font-size: 0.9375rem;
    outline: none;
    font-family: inherit;
    color: var(--text-primary);
}

.message-input::placeholder {
    color: var(--text-secondary);
}

/* Telegram-style Voice Recording Button */
.voice-record-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    position: relative;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.voice-record-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}

.voice-record-btn:active {
    transform: scale(0.95);
}

.voice-record-btn.recording {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    animation: recordPulse 1.5s infinite;
}

@keyframes recordPulse {
    0%, 100% { 
        transform: scale(1); 
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
    }
    50% { 
        transform: scale(1.05); 
        box-shadow: 0 0 0 15px rgba(239, 68, 68, 0);
    }
}

.voice-record-btn svg {
    width: 24px;
    height: 24px;
    color: white;
}

.send-button {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-right: 0.75rem;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.send-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}

.send-button:active {
    transform: scale(0.95);
}

.send-button svg {
    width: 22px;
    height: 22px;
    color: white;
    transform: scaleX(-1);
}

/* Recording Overlay - Telegram Style */
.recording-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--surface);
    display: none;
    align-items: center;
    padding: 1rem;
    gap: 1rem;
    border-radius: 24px;
}

.recording-overlay.active {
    display: flex;
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-to-cancel {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    animation: slideHint 2s ease-in-out infinite;
}

@keyframes slideHint {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(-10px); }
}

.slide-to-cancel svg {
    width: 20px;
    height: 20px;
}

.recording-timer {
    color: #ef4444;
    font-weight: 600;
    font-size: 1rem;
    min-width: 45px;
}

.recording-waveform {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
}

.recording-bar {
    width: 4px;
    background: #ef4444;
    border-radius: 2px;
    animation: recordWave 0.6s ease-in-out infinite;
}

.recording-bar:nth-child(1) { height: 10px; animation-delay: 0s; }
.recording-bar:nth-child(2) { height: 20px; animation-delay: 0.1s; }
.recording-bar:nth-child(3) { height: 15px; animation-delay: 0.2s; }
.recording-bar:nth-child(4) { height: 25px; animation-delay: 0.3s; }
.recording-bar:nth-child(5) { height: 18px; animation-delay: 0.4s; }

@keyframes recordWave {
    0%, 100% { transform: scaleY(1); opacity: 0.5; }
    50% { transform: scaleY(1.5); opacity: 1; }
}

/* Admin Screen - Enhanced */
#admin-screen {
    background: var(--background);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 1rem;
    padding-top: calc(1.5rem + env(safe-area-inset-top, 0px));
    background: var(--surface);
    color: var(--text-primary);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.admin-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logout-button {
    background: rgba(239, 68, 68, 0.1);
    border: none;
    color: #ef4444;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logout-button:hover {
    background: rgba(239, 68, 68, 0.2);
    transform: translateY(-1px);
}

.logout-button svg {
    width: 18px;
    height: 18px;
}

.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
}

.admin-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    background: var(--surface);
    padding: 0.5rem;
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.admin-tab {
    flex: 1;
    background: transparent;
    border: none;
    padding: 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.admin-tab svg {
    width: 18px;
    height: 18px;
}

.admin-tab:hover {
    color: var(--text-primary);
    background: var(--surface-light);
}

.admin-tab.active {
    color: white;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.admin-content {
    background: var(--surface);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: var(--shadow);
}

.admin-tab-content {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.admin-tab-content.active {
    display: block;
}

.admin-tab-content h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

/* History Tab */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.history-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.clear-button {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: none;
    padding: 0.625rem 1.25rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.clear-button:hover {
    background: rgba(239, 68, 68, 0.2);
    transform: translateY(-1px);
}

.clear-button svg {
    width: 16px;
    height: 16px;
}

.history-list {
    max-height: 60vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-right: 0.5rem;
}

.history-item {
    background: var(--background);
    padding: 1.25rem;
    border-radius: 16px;
    margin-bottom: 1rem;
    transition: all 0.2s ease;
    border: 1px solid var(--border);
}

.history-item:hover {
    background: var(--surface-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.history-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.user-type-tag {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.625rem;
    font-weight: 600;
}

.user-type-tag.new {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2) 0%, rgba(16, 185, 129, 0.3) 100%);
    color: var(--secondary);
}

.user-type-tag.existing {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2) 0%, rgba(59, 130, 246, 0.3) 100%);
    color: var(--primary);
}

.history-question {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.history-response {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.6;
}

/* Form Styles - Enhanced */
.faq-section {
    margin-bottom: 2rem;
}

.faq-section h4 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1rem;
}

.faq-textarea,
.setting-input,
.setting-textarea {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 0.9375rem;
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
    background: var(--background);
    color: var(--text-primary);
    resize: vertical;
}

.faq-textarea:focus,
.setting-input:focus,
.setting-textarea:focus {
    border-color: var(--primary);
    background: var(--surface-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.setting-group {
    margin-bottom: 2rem;
}

.setting-group label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.setting-group small {
    display: block;
    margin-top: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

.input-with-icon {
    position: relative;
}

.input-with-icon svg {
    position: absolute;
    top: 50%;
    right: 1rem;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
}

.input-with-icon input {
    padding-right: 3rem;
}

.save-button {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.save-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.save-button svg {
    width: 20px;
    height: 20px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(10px);
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinning {
    animation: spin 1s linear infinite;
    display: inline-block;
}

/* Typing Indicator */
.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 8px 12px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .splash-title {
        font-size: 2rem;
    }

    .welcome-title {
        font-size: 2.25rem;
    }

    .message-bubble {
        max-width: 85%;
    }

    .admin-tabs {
        flex-wrap: wrap;
    }

    .admin-tab {
        flex: 1 1 calc(50% - 0.25rem);
        font-size: 0.8125rem;
        padding: 0.75rem 0.5rem;
    }

    .admin-tab svg {
        width: 16px;
        height: 16px;
    }

    .admin-content {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .splash-title {
        font-size: 1.75rem;
    }

    .welcome-title {
        font-size: 2rem;
    }

    .primary-button,
    .secondary-button {
        padding: 1rem 1.5rem;
        font-size: 1rem;
    }

    .message-bubble {
        font-size: 0.875rem;
    }
}

/* Landscape Mode Adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    .animated-icons {
        height: 150px;
        margin-bottom: 1rem;
    }

    .splash-title {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }

    .logo-container {
        margin-bottom: 1.5rem;
    }

    .logo {
        width: 140px;
        height: 140px;
    }

    .welcome-title {
        font-size: 1.75rem;
    }

    .chat-header {
        padding: 0.5rem 0.75rem;
        min-height: 50px;
    }
}
