/* ============================================================================
   ShayraChatAI — Professional Chat Interface
   ============================================================================ */

/* ---------- CSS Variables / Theme ---------- */
:root {
    --primary: #e91e8c;
    --primary-light: #f472b6;
    --primary-dark: #be185d;
    --primary-glow: rgba(233, 30, 140, 0.3);

    --bg-dark: #0f0f14;
    --bg-sidebar: #16161e;
    --bg-main: #1a1a24;
    --bg-card: #22222e;
    --bg-input: #1e1e2a;
    --bg-hover: #2a2a38;
    --bg-bubble-user: linear-gradient(135deg, #e91e8c, #a855f7);
    --bg-bubble-bot: #22222e;

    --text-primary: #f0f0f5;
    --text-secondary: #9ca3af;
    --text-dim: #6b7280;
    --text-on-primary: #ffffff;

    --border: #2d2d3a;
    --border-light: #3d3d4a;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 20px var(--primary-glow);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    --sidebar-width: 280px;
    --topbar-height: 64px;
    --input-height: 72px;

    --transition: 0.2s ease;
    --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);

    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'Poppins', 'Inter', sans-serif;
}

/* ---------- Reset ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-main);
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    outline: none;
}

textarea {
    font-family: inherit;
    border: none;
    outline: none;
    resize: none;
}

img {
    display: block;
    max-width: 100%;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* ---------- Layout ---------- */
.app-container {
    display: flex;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

/* ============================================================================
   SIDEBAR
   ============================================================================ */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-slow);
    z-index: 100;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 32px;
    height: 32px;
}

.logo-text {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-close {
    display: none;
    padding: 6px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: var(--transition);
}
.sidebar-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* New Chat Button */
.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 12px 8px;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    border: 1px dashed var(--border-light);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
}
.new-chat-btn:hover {
    border-color: var(--primary-light);
    color: var(--primary-light);
    background: rgba(233, 30, 140, 0.05);
}

/* Model Selector */
.model-selector {
    padding: 12px;
}

.model-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    padding: 0 4px;
}

.model-options {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.model-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    text-align: left;
}
.model-option:hover {
    background: var(--bg-hover);
}
.model-option.active {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
}

.model-option-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.dot-shayra { background: var(--primary); }
.dot-pro { background: #8b5cf6; }
.dot-promax { background: #06b6d4; }

.model-option-info {
    display: flex;
    flex-direction: column;
}
.model-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}
.model-desc {
    font-size: 0.72rem;
    color: var(--text-dim);
}

/* Chat History */
.chat-history {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0 12px;
}

.chat-history-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 8px 4px 6px;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: var(--transition);
    cursor: pointer;
}
.chat-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.chat-item.active {
    background: var(--bg-card);
    color: var(--text-primary);
}
.chat-item-icon {
    flex-shrink: 0;
    opacity: 0.6;
}
.chat-item-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-item-delete {
    opacity: 0;
    padding: 2px;
    border-radius: 4px;
    color: var(--text-dim);
    transition: var(--transition);
}
.chat-item:hover .chat-item-delete {
    opacity: 1;
}
.chat-item-delete:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}
.sidebar-footer-text {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-align: center;
}

/* ============================================================================
   MAIN AREA
   ============================================================================ */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
    height: 100%;
    overflow: hidden;
}

/* ---------- Top Bar ---------- */
.top-bar {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-main);
    gap: 12px;
    flex-shrink: 0;
}

.menu-btn {
    display: none;
    padding: 8px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: var(--transition);
}
.menu-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.top-bar-center {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.top-bar-avatar {
    position: relative;
    width: 38px;
    height: 38px;
}
.avatar-img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid var(--primary);
}
.online-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    background: #22c55e;
    border: 2px solid var(--bg-main);
    border-radius: 50%;
}

.top-bar-info {
    display: flex;
    flex-direction: column;
}
.top-bar-name {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}
.top-bar-status {
    font-size: 0.75rem;
    color: #22c55e;
}

.clear-btn {
    padding: 8px;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    transition: var(--transition);
}
.clear-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* ---------- Chat Area ---------- */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
}

/* Welcome Screen */
.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 16px;
    animation: fadeInUp 0.6s ease-out;
}

.welcome-avatar {
    position: relative;
    width: 100px;
    height: 100px;
    margin-bottom: 8px;
}
.welcome-avatar-img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 3px solid var(--primary);
    position: relative;
    z-index: 1;
}
.welcome-avatar-glow {
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    background: var(--primary-glow);
    filter: blur(16px);
    animation: pulseGlow 3s ease-in-out infinite;
}

.welcome-title {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
}
.gradient-text {
    background: linear-gradient(135deg, var(--primary), #a855f7, #06b6d4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 400px;
    line-height: 1.6;
}

.welcome-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 12px;
}
.chip {
    padding: 8px 16px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-light);
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: var(--transition);
    white-space: nowrap;
}
.chip:hover {
    border-color: var(--primary-light);
    color: var(--primary-light);
    background: rgba(233, 30, 140, 0.08);
    transform: translateY(-1px);
}

/* Messages */
.messages-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-bottom: 8px;
}

.message-group {
    display: flex;
    gap: 8px;
    max-width: 75%;
    animation: fadeInUp 0.3s ease-out;
}
.message-group.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.message-group.bot {
    align-self: flex-start;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 4px;
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message-bubble {
    padding: 10px 16px;
    border-radius: var(--radius-lg);
    font-size: 0.92rem;
    line-height: 1.55;
    word-break: break-word;
    position: relative;
}

.message-group.user .message-bubble {
    background: var(--bg-bubble-user);
    color: var(--text-on-primary);
    border-bottom-right-radius: 6px;
}

.message-group.bot .message-bubble {
    background: var(--bg-bubble-bot);
    color: var(--text-primary);
    border-bottom-left-radius: 6px;
    border: 1px solid var(--border);
}

/* Multiple bot bubbles stacked */
.message-group.bot .message-bubble + .message-bubble {
    border-top-left-radius: var(--radius-lg);
    margin-top: 4px;
}

.message-time {
    font-size: 0.7rem;
    color: var(--text-dim);
    padding: 0 8px;
}
.message-group.user .message-time {
    text-align: right;
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    align-items: flex-end;
    gap: 8px;
    padding: 4px 0;
    animation: fadeIn 0.3s ease-out;
}
.typing-indicator.visible {
    display: flex;
}
.typing-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}
.typing-avatar-img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}
.typing-bubble {
    background: var(--bg-bubble-bot);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    border-bottom-left-radius: 6px;
    padding: 12px 18px;
}
.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}
.typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-dim);
    animation: typingBounce 1.4s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* ---------- Input Area ---------- */
.input-area {
    padding: 12px 20px calc(16px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border);
    background: var(--bg-main);
    flex-shrink: 0;
}

.input-container {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 6px 6px 6px 16px;
    transition: border-color var(--transition);
}
.input-container:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(233, 30, 140, 0.15);
}

.message-input {
    flex: 1;
    min-height: 24px;
    max-height: 120px;
    padding: 8px 0;
    font-size: 0.92rem;
    color: var(--text-primary);
    background: transparent;
    line-height: 1.5;
}
.message-input::placeholder {
    color: var(--text-dim);
}

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: white;
    transition: var(--transition);
    flex-shrink: 0;
}
.send-btn:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: scale(1.05);
}
.send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.input-footer {
    display: flex;
    justify-content: flex-end;
    padding: 4px 4px 0;
}
.char-count {
    font-size: 0.7rem;
    color: var(--text-dim);
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulseGlow {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.08); }
}

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        height: 100dvh;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
        z-index: 100;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-close {
        display: flex;
    }
    .menu-btn {
        display: flex;
    }
    .main-area {
        height: 100vh;
        height: 100dvh;
        display: flex;
        flex-direction: column;
    }
    .chat-area {
        flex: 1;
        min-height: 0;
    }
    .message-group {
        max-width: 88%;
    }
    .welcome-title {
        font-size: 1.4rem;
    }
    .welcome-screen {
        padding: 20px 16px;
    }
    .welcome-avatar {
        width: 80px;
        height: 80px;
    }
    .welcome-avatar-img {
        width: 80px;
        height: 80px;
    }
    .welcome-chips {
        gap: 6px;
        flex-wrap: wrap;
        justify-content: center;
    }
    .chip {
        font-size: 0.8rem;
        padding: 6px 12px;
    }
    .input-area {
        padding: 8px 12px calc(12px + env(safe-area-inset-bottom, 0px));
    }
    .input-footer {
        display: none;
    }
}

@media (max-width: 480px) {
    .chat-area {
        padding: 10px 8px;
    }
    .input-area {
        padding: 6px 8px calc(10px + env(safe-area-inset-bottom, 0px));
    }
    .message-group {
        max-width: 92%;
    }
    .welcome-title {
        font-size: 1.2rem;
    }
    .welcome-subtitle {
        font-size: 0.85rem;
    }
    .top-bar {
        padding: 8px 12px;
    }
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}
.sidebar-overlay.visible {
    display: block;
}
