/* ============================================
   StudioAICore Chat App - Paper Material Style
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800&display=swap');

:root {
    --primary: #3D5A80;
    --primary-dark: #2B4162;
    --primary-light: #5B8DB8;
    --secondary: #EE6C4D;
    --secondary-dark: #D4553A;

    --paper-bg: #F5F1EB;
    --paper-warm: #EDE8E0;
    --card-white: #FFFFFF;
    --dark: #293241;
    --darker: #1C232E;
    --text: #3D3D3D;
    --text-light: #7A7A7A;
    --text-muted: #A0A0A0;

    --shadow-xs: 0 1px 2px rgba(0,0,0,0.06);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.12);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 24px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.06);
    --shadow-xl: 0 16px 32px rgba(0,0,0,0.12), 0 8px 16px rgba(0,0,0,0.06);
    --shadow-paper: 2px 2px 0 rgba(0,0,0,0.04), 4px 4px 0 rgba(0,0,0,0.02);

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --font: 'Nunito', sans-serif;
    --transition: 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    background: var(--paper-bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: var(--primary);
    transition: var(--transition);
}

a:hover {
    color: var(--secondary);
}

/* ============================================
   App Layout
   ============================================ */
.app-layout {
    display: flex;
    height: 100vh;
}

/* ============================================
   Sidebar - Paper card
   ============================================ */
.sidebar {
    width: 280px;
    background: var(--card-white);
    border-right: 1px solid rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 8px rgba(0,0,0,0.04);
    flex-shrink: 0;
    z-index: 10;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--dark);
    margin-bottom: 16px;
    text-decoration: none;
}

.sidebar-logo-icon {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm), var(--shadow-paper);
}

.sidebar-logo-icon svg {
    width: 18px;
    height: 18px;
    fill: white;
}

.new-chat-btn {
    width: 100%;
    padding: 10px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: var(--shadow-sm), 2px 2px 0 var(--primary-dark);
    transition: var(--transition);
}

.new-chat-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md), 3px 3px 0 var(--primary-dark);
}

/* Chat history */
.sidebar-chats {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.sidebar-date {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 12px 4px;
}

.sidebar-chat-item {
    padding: 10px 12px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-chat-item:hover,
.sidebar-chat-item.active {
    background: var(--paper-bg);
    box-shadow: var(--shadow-xs);
}

.sidebar-chat-item.active {
    color: var(--primary);
    font-weight: 600;
}

/* Sidebar footer */
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(0,0,0,0.06);
    background: var(--paper-bg);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.sidebar-avatar {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    box-shadow: var(--shadow-xs);
}

.sidebar-user-info {
    flex: 1;
}

.sidebar-user-info strong {
    display: block;
    font-size: 0.85rem;
    color: var(--dark);
}

.sidebar-user-info span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sidebar-links {
    display: flex;
    gap: 16px;
}

.sidebar-links a {
    font-size: 0.8rem;
    color: var(--text-light);
    font-weight: 600;
}

/* ============================================
   Main Chat Area
   ============================================ */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

/* Mobile sidebar toggle */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 20;
    background: var(--card-white);
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: var(--radius-md);
    padding: 10px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    line-height: 1;
    font-size: 1.2rem;
}

/* Chat messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    display: flex;
    flex-direction: column;
}

/* Empty state */
.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
}

.chat-empty-logo {
    width: 72px;
    height: 72px;
    background: var(--primary);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    box-shadow: var(--shadow-lg), 4px 4px 0 var(--primary-dark);
    animation: float-logo 4s ease-in-out infinite;
}

@keyframes float-logo {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.chat-empty-logo svg {
    width: 36px;
    height: 36px;
    fill: white;
}

.chat-empty h2 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--dark);
    margin-bottom: 8px;
}

.chat-empty p {
    color: var(--text-light);
    font-size: 1rem;
    margin-bottom: 12px;
}

.chat-empty .bonus-text {
    font-size: 1.7rem;
    color: var(--primary);
    font-weight: 700;
    margin: 1.5rem 0;
    line-height: 1.6;
}

/* Suggestion cards */
.suggestions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    max-width: 560px;
    width: 100%;
    margin-top: 24px;
}

.suggestion-card {
    background: var(--card-white);
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: var(--radius-lg);
    padding: 16px;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    box-shadow: var(--shadow-sm), var(--shadow-paper);
}

.suggestion-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md), 3px 3px 0 rgba(61,90,128,0.1);
}

.suggestion-card h4 {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 4px;
}

.suggestion-card p {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* Chat messages */
.message {
    max-width: 720px;
    margin-bottom: 24px;
    display: flex;
    gap: 12px;
    animation: msg-in 0.3s ease forwards;
}

@keyframes msg-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    flex-direction: row-reverse;
    align-self: flex-end;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
    box-shadow: var(--shadow-xs);
}

.message.bot .message-avatar {
    background: var(--primary);
    color: white;
}

.message.user .message-avatar {
    background: var(--secondary);
    color: white;
}

.message-content {
    border-radius: var(--radius-lg);
    padding: 14px 18px;
    font-size: 0.92rem;
    line-height: 1.7;
    box-shadow: var(--shadow-sm);
}

.message.bot .message-content {
    background: var(--card-white);
    border: 1px solid rgba(0,0,0,0.05);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm), var(--shadow-paper);
}

.message.user .message-content {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: var(--shadow-sm), 2px 2px 0 var(--primary-dark);
}

.message-content a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: underline;
}

.message.user .message-content a {
    color: #b8d4f0;
}

.message-content code {
    background: var(--paper-warm);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.85em;
}

.message.user .message-content code {
    background: rgba(255,255,255,0.15);
}

.message-content pre {
    background: var(--darker);
    border-radius: var(--radius-md);
    padding: 16px;
    margin: 10px 0;
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}

.message-content pre code {
    background: none;
    padding: 0;
    color: #e4e4e7;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 14px 18px;
    background: var(--card-white);
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: var(--radius-lg);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: var(--shadow-sm);
    margin-left: 48px;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ============================================
   Input Area
   ============================================ */
.chat-input-area {
    padding: 16px 32px 24px;
    background: var(--paper-bg);
    border-top: 1px solid rgba(0,0,0,0.04);
}

.chat-input-wrapper {
    max-width: 720px;
    margin: 0 auto;
    background: var(--card-white);
    border-radius: var(--radius-lg);
    border: 2px solid rgba(0,0,0,0.08);
    display: flex;
    align-items: flex-end;
    padding: 8px;
    box-shadow: var(--shadow-md), var(--shadow-paper);
    transition: var(--transition);
}

.chat-input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: var(--shadow-lg), var(--shadow-paper);
}

.chat-input-wrapper textarea {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-family: var(--font);
    font-size: 0.95rem;
    color: var(--text);
    padding: 8px 12px;
    background: transparent;
    max-height: 120px;
    line-height: 1.5;
}

.chat-input-wrapper textarea::placeholder {
    color: var(--text-muted);
}

.send-btn {
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-xs), 2px 2px 0 var(--primary-dark);
    transition: var(--transition);
    flex-shrink: 0;
}

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

.send-btn svg {
    width: 18px;
    height: 18px;
    fill: white;
}

.chat-disclaimer {
    text-align: center;
    margin-top: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -300px;
        top: 0;
        bottom: 0;
        z-index: 100;
        transition: left 0.3s;
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-toggle {
        display: block;
    }

    .chat-messages {
        padding: 60px 16px 16px;
    }

    .chat-input-area {
        padding: 12px 16px 16px;
    }

    .suggestions {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .chat-empty h2 {
        font-size: 1.3rem;
    }

    .chat-empty .bonus-text {
        font-size: 1.3rem;
    }

    .message-content {
        padding: 12px 14px;
        font-size: 0.88rem;
    }
}

/* Mobile sidebar overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 50;
}

.sidebar-overlay.active {
    display: block;
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .chat-empty-logo {
        width: 48px;
        height: 48px;
        margin-bottom: 12px;
    }

    .chat-empty h2 {
        font-size: 1.2rem;
    }

    .suggestions {
        grid-template-columns: repeat(4, 1fr);
    }
}
