:root {
    --bg-dark: #0a0f1c;
    --bg-card: rgba(20, 28, 47, 0.6);
    --bg-card-hover: rgba(30, 41, 67, 0.8);
    
    --primary: #d4af37; /* Gold */
    --primary-hover: #b8962e;
    --secondary: #4a6fa5;
    
    --text-main: #f0f4f8;
    --text-muted: #94a3b8;
    
    --sidebar-bg: rgba(13, 18, 30, 0.7);
    --border-color: rgba(255, 255, 255, 0.08);
    
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    --glass-blur: blur(16px);
    
    --font-ui: 'Inter', 'Noto Sans JP', sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-ui);
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* Background animated shapes for Glassmorphism effect */
.bg-shape {
    position: absolute;
    filter: blur(80px);
    z-index: -1;
    border-radius: 50%;
    animation: float 20s infinite ease-in-out alternate;
}

.shape1 {
    top: -10%; left: -10%;
    width: 50vw; height: 50vw;
    background: radial-gradient(circle, rgba(28,52,107,0.4) 0%, rgba(10,15,28,0) 70%);
    animation-delay: 0s;
}

.shape2 {
    bottom: -20%; right: -10%;
    width: 60vw; height: 60vw;
    background: radial-gradient(circle, rgba(74,111,165,0.2) 0%, rgba(10,15,28,0) 70%);
    animation-delay: -5s;
}

.shape3 {
    top: 40%; left: 60%;
    width: 30vw; height: 30vw;
    background: radial-gradient(circle, rgba(212,175,55,0.1) 0%, rgba(10,15,28,0) 70%);
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(5%, 10%) scale(1.1); }
}

/* Layout */
.app-wrapper {
    display: flex;
    height: 100vh;
    width: 100vw;
    backdrop-filter: blur(5px);
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    z-index: 10;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 2.5rem;
}

.logo-icon {
    font-size: 2rem;
    color: var(--primary);
}

.logo-text {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(90deg, #fff, #bbb);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
}

/* Custom Scrollbar for sidebar & chat */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.2);
}

.nav-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.8rem;
    font-weight: 600;
}

.nav-list {
    list-style: none;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    margin-bottom: 0.2rem;
}

.nav-item i {
    font-size: 1.2rem;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-item.active {
    background: rgba(212, 175, 55, 0.1);
    color: var(--primary);
    border-left: 3px solid var(--primary);
}

.history-item {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, #8a701e 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #000;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
}

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

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Header */
.top-header {
    height: 70px;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: rgba(10, 15, 28, 0.4);
    backdrop-filter: var(--glass-blur);
    z-index: 5;
}

.page-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.primary-btn {
    background: var(--primary);
    color: #000;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

/* Chat Area */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
}

/* Welcome Screen */
.welcome-screen {
    margin: auto;
    max-width: 800px;
    text-align: center;
    animation: fadeIn 0.5s ease-out;
}

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

.welcome-icon {
    font-size: 4rem;
    color: var(--primary);
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 20px rgba(212, 175, 55, 0.4));
}

.welcome-screen h2 {
    font-size: 2.2rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.welcome-screen p {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 3rem;
}

.suggestions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    text-align: left;
}

.suggestion-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 1.2rem;
    border-radius: 12px;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
}

.suggestion-card i {
    font-size: 1.5rem;
    color: var(--primary);
    background: rgba(212, 175, 55, 0.1);
    padding: 0.5rem;
    border-radius: 8px;
}

.suggestion-card:hover {
    background: var(--bg-card-hover);
    border-color: rgba(212, 175, 55, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.suggest-title {
    display: block;
    font-weight: 600;
    margin-bottom: 0.2rem;
    color: var(--text-main);
}

.suggest-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Messages Wrapper */
.messages-wrapper {
    max-width: 850px;
    margin: 0 auto;
    width: 100%;
    padding-bottom: 2rem;
}

.message-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    animation: slideUp 0.4s ease-out;
}

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

.msg-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-weight: bold;
}

.msg-user .msg-avatar {
    background: linear-gradient(135deg, var(--primary) 0%, #8a701e 100%);
    color: #000;
}

.msg-ai .msg-avatar {
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary);
    border: 1px solid rgba(212, 175, 55, 0.3);
    font-size: 1.2rem;
}

.msg-content {
    flex: 1;
    line-height: 1.6;
    font-size: 1rem;
}

.msg-user .msg-content {
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

/* Markdown Styles for AI Response */
.msg-ai .msg-content {
    padding-top: 0.4rem;
}
.msg-ai .msg-content p { margin-bottom: 1rem; }
.msg-ai .msg-content strong { color: var(--primary); }
.msg-ai .msg-content ul { padding-left: 1.5rem; margin-bottom: 1rem; }
.msg-ai .msg-content li { margin-bottom: 0.3rem; }

/* Sources Card in AI response */
.sources-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
    font-size: 0.85rem;
}
.sources-title {
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: flex; align-items: center; gap: 0.4rem;
}
.source-item {
    display: inline-flex; align-items: center; gap: 0.3rem;
    background: rgba(212, 175, 55, 0.1);
    color: var(--primary);
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    margin-right: 0.5rem; margin-bottom: 0.5rem;
    cursor: pointer;
    transition: background 0.2s;
}
.source-item:hover {
    background: rgba(212, 175, 55, 0.2);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding-top: 0.8rem;
}
.dot {
    width: 6px; height: 6px;
    background: var(--primary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}
.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes typing {
    0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Input Area */
.input-area-wrapper {
    padding: 1.5rem 2rem 2rem;
    background: linear-gradient(to top, var(--bg-dark) 50%, transparent);
    z-index: 5;
}

.input-container {
    max-width: 850px;
    margin: 0 auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 0.5rem;
    display: flex;
    align-items: flex-end;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    backdrop-filter: var(--glass-blur);
    transition: border-color 0.3s, box-shadow 0.3s;
}

.input-container:focus-within {
    border-color: rgba(212, 175, 55, 0.5);
    box-shadow: 0 0 0 1px rgba(212, 175, 55, 0.5), 0 10px 30px rgba(0,0,0,0.5);
}

.attach-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    padding: 0.8rem;
    cursor: pointer;
    border-radius: 8px;
    transition: color 0.2s;
}
.attach-btn:hover { color: var(--text-main); }

#search-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    padding: 0.8rem;
    resize: none;
    max-height: 200px;
    outline: none;
    line-height: 1.5;
}
#search-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.send-btn {
    background: var(--primary);
    color: #000;
    border: none;
    width: 40px; height: 40px;
    border-radius: 8px;
    font-size: 1.2rem;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    margin: 0.4rem;
    transition: all 0.2s;
}
.send-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}
.send-btn:disabled {
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.3);
    cursor: not-allowed;
    transform: none;
}

.input-footer {
    max-width: 850px;
    margin: 0.5rem auto 0;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}
