/* =================================================================== */
/* --- SMART AI PRO FRONTEND - FINAL, UNIFIED & COMPLETE STYLESHEET --- */
/* =================================================================== */

/* --- 1. GLOBAL VARIABLES & RESET --- */
:root {
    --bg-primary: #121212;
    --bg-secondary: #1E1E1E;
    --bg-tertiary: #2a2a2a;
    --text-primary: #e0e0e0;
    --text-secondary: #888888;
    --border-color: #333333;
    --accent-primary: #007BFF;
    --accent-pro: #9a66ff;
    --success-color: #4CAF50;
    --error-color: #f44336;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    /* Responsive font size */
    font-size: clamp(14px, 1.5vw, 16px);
}


/* --- Custom Scrollbar --- */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: #555; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #777; }

/* --- Helper Classes --- */
.error-message { color: var(--error-color); font-size: 0.85rem; margin-top: 1rem; height: 1rem; text-align: center; }

/* =================================== */
/* --- 2. AUTHENTICATION VIEW --- */
/* =================================== */
#auth-view { display: flex; justify-content: center; align-items: center; height: 100vh; width: 100vw; position: fixed; top: 0; left: 0; z-index: 100; }
#bg-canvas { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; background-color: #000000; }
.auth-card { width: 380px; padding: 2.5rem; border-radius: 15px; background: rgba(18, 18, 18, 0.7); backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px); border: 1px solid rgba(255, 255, 255, 0.1); box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5); text-align: center; color: var(--text-primary); }
.auth-card h2 { margin-bottom: 2rem; font-weight: 600; color: #ffffff; }
.auth-card .input-group { position: relative; margin-bottom: 1.5rem; }
.auth-card input { width: 100%; padding: 0.9rem 1rem; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--border-color); border-radius: 8px; color: var(--text-primary); font-size: 1rem; transition: all 0.3s ease; }
.auth-card input:focus { outline: none; border-color: rgba(255, 255, 255, 0.5); box-shadow: 0 0 15px rgba(255, 255, 255, 0.2); }
.auth-button { width: 100%; padding: 0.9rem; border-radius: 8px; border: none; background-color: #ffffff; color: #000000; font-size: 1.1rem; font-weight: 600; cursor: pointer; transition: all 0.3s ease; }
.auth-button:hover { background-color: #dcdcdc; }
.auth-button:disabled { background-color: #555; cursor: not-allowed; }
.toggle-link { margin-top: 1.5rem; font-size: 0.9rem; color: var(--text-secondary); }
.toggle-link a { color: #ffffff; text-decoration: none; font-weight: 600; transition: color 0.3s; }
.toggle-link a:hover { color: #bbbbbb; }

/* =================================== */
/* --- 3. MAIN APP LAYOUT & SIDEBAR --- */
/* =================================== */
#app-container { display: grid; grid-template-columns: 260px 1fr; height: 100vh; width: 100vw; }
#sidebar { background-color: var(--bg-secondary); border-right: 1px solid var(--border-color); padding: 1rem; display: flex; flex-direction: column; overflow-y: auto; }
.sidebar-header {
    padding: 0.5rem;
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
    font-weight: 600;
    display: flex;
    align-items: center;
}
.sidebar-logo {
    width: 32px;
    height: 32px;
    margin-right: 12px;
    border-radius: 6px; /* Optional: for slightly rounded corners */
}

#user-profile { padding: 0.8rem; margin-bottom: 1rem; border-top: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color); }
#user-email { display: block; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 0.5rem; }
.pro-badge, .standard-badge { font-size: 0.75rem; padding: 3px 8px; border-radius: 5px; font-weight: bold; }
.pro-badge { background: linear-gradient(90deg, #8e44ad, #9b59b6); color: white; }
.standard-badge { background-color: var(--bg-tertiary); color: var(--text-secondary); }
.sidebar-nav { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.5rem; }
.sidebar-nav button { width: 100%; padding: 0.75rem; background-color: var(--bg-tertiary); border: 1px solid var(--border-color); color: var(--text-primary); border-radius: 8px; text-align: left; cursor: pointer; transition: background-color 0.2s; }
.sidebar-nav button:hover, .sidebar-nav button.active { background-color: #3a3a3a; }
.sidebar-header svg {
    margin-right: 10px;
    color: var(--text-primary);
}
.sidebar-nav button {
    display: flex; /* To align icon and text */
    align-items: center;
}
.sidebar-nav button svg {
    margin-right: 10px;
    stroke-width: 2; /* Control SVG thickness */
}
#logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
}
#logout-btn svg {
    margin-right: 10px;
}

.mode-switch-container { padding: 10px 8px; margin-top: 1rem; border-top: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.sidebar-section { margin-bottom: 1.5rem; }
.sidebar-section h4 { color: var(--text-secondary); font-size: 0.8rem; text-transform: uppercase; margin-bottom: 0.8rem; padding: 0 0.5rem; }
.sidebar-section ul { list-style: none; }
.sidebar-section ul li a { display: block; padding: 0.6rem 0.8rem; color: var(--text-secondary); text-decoration: none; border-radius: 6px; transition: background-color 0.2s, color 0.2s; }
.sidebar-section ul li a:hover { background-color: var(--bg-tertiary); color: var(--text-primary); }
.sidebar-section ul li a.active { background-color: var(--accent-primary); color: white; }
.sidebar-footer { margin-top: auto; }
#logout-btn { width: 100%; padding: 0.75rem; background-color: transparent; border: 1px solid var(--border-color); color: var(--text-secondary); border-radius: 8px; cursor: pointer; transition: all 0.2s; }
#logout-btn:hover { background-color: var(--error-color); color: white; border-color: var(--error-color); }

/* =================================== */
/* --- 4. MAIN CHAT VIEW --- */
/* =================================== */
#main-content { background-color: var(--bg-primary); display: flex; flex-direction: column; overflow: hidden; position: relative; }
#chat-welcome { position: absolute; top: 45%; left: 50%; transform: translate(-50%, -50%); text-align: center; pointer-events: none; transition: opacity 0.3s ease; z-index: 1; }
#chat-welcome h1 { font-size: 2.5rem; font-weight: 600; color: var(--text-primary); }
#chat-welcome p { font-size: 1.2rem; color: var(--text-secondary); }
#chat-view { display: grid; grid-template-rows: auto 1fr auto; height: 100%; overflow: hidden; position: relative; z-index: 2; }
#chat-view.has-messages #chat-welcome { opacity: 0; }
.chat-header { padding: 1rem 1.5rem; border-bottom: 1px solid var(--border-color); background-color: var(--bg-secondary); display: flex; justify-content: space-between; align-items: center; }
.chat-header-controls { display: flex; align-items: center; gap: 20px; }
#mode-selector-container, #kb-selector-container { display: flex; align-items: center; gap: 8px; }
#mode-selector-container label, #kb-selector-container label, .switch-label { font-size: 0.9rem; color: var(--text-secondary); }
#mode-selector, #kb-chat-selector { background-color: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border-color); border-radius: 8px; padding: 5px 10px; font-size: 0.9rem; cursor: pointer; }
#mode-selector:focus, #kb-chat-selector:focus { outline: none; border-color: var(--accent-primary); }
#unfiltered-mode-container { display: flex; align-items: center; gap: 10px; }
.switch { position: relative; display: inline-block; width: 50px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--bg-tertiary); transition: .4s; }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 4px; bottom: 4px; background-color: white; transition: .4s; }
input:checked + .slider { background-color: var(--accent-pro); }
input:checked + .slider:before { transform: translateX(22px); }
.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }
#chat-messages { padding: 1.5rem; overflow-y: auto; display: flex; flex-direction: column; gap: 1.2rem; }
.message-wrapper { display: flex; }
.message-user-wrapper { justify-content: flex-end; }
.message-assistant-wrapper, .message-collaborator-wrapper, .message-system-wrapper, .message-error-wrapper { justify-content: flex-start; }
.message { max-width: 75%; padding: 0.8rem 1.2rem; border-radius: 18px; line-height: 1.5; word-wrap: break-word; }
.message.assistant { background-color: var(--bg-secondary); border-bottom-left-radius: 4px; display: flex; align-items: center; justify-content: space-between; }
.message.user { background-color: var(--accent-primary); color: white; border-bottom-right-radius: 4px; }
.message.collaborator { background-color: #3e4b59; border-bottom-left-radius: 4px; }
.sender-label { display: block; font-size: 0.75rem; font-weight: bold; color: var(--text-secondary); margin-bottom: 5px; }
.speak-btn { background: transparent; border: none; color: var(--text-secondary); width: 30px; height: 30px; border-radius: 50%; cursor: pointer; margin-left: 10px; transition: all 0.2s; font-size: 1rem; }
.speak-btn:hover { color: var(--text-primary); }
#typing-indicator { padding: 0 1.5rem; height: 30px; }
#typing-indicator span { height: 10px; width: 10px; background-color: var(--text-secondary); border-radius: 50%; display: inline-block; animation: typing-wave 1.4s infinite ease-in-out both; }
#typing-indicator span:nth-of-type(1) { animation-delay: -0.32s; }
#typing-indicator span:nth-of-type(2) { animation-delay: -0.16s; }
@keyframes typing-wave { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1.0); } }
.chat-input-area { padding: 1rem 1.5rem; border-top: 1px solid var(--border-color); background-color: var(--bg-primary); z-index: 5; }
#chat-form { display: flex; align-items: center; gap: 1rem; }
#chat-input { flex-grow: 1; padding: 0.9rem 1.2rem; border-radius: 12px; border: 1px solid var(--border-color); background-color: var(--bg-tertiary); color: var(--text-primary); font-size: 1rem; resize: none; max-height: 150px; }
#chat-input:focus { outline: none; border-color: var(--accent-primary); }
#send-btn, #vision-mode-btn { flex-shrink: 0; width: 48px; height: 48px; border-radius: 50%; border: none; background-color: var(--accent-primary); color: white; font-size: 1.2rem; cursor: pointer; transition: background-color 0.2s; }
#attach-file-btn {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
}
#attach-file-btn:hover {
    background-color: var(--accent-primary);
    color: white;
}

#vision-mode-btn { background-color: var(--bg-tertiary); border: 1px solid var(--border-color); color: var(--text-primary); }
#vision-mode-btn.active, #vision-mode-btn:hover { background-color: var(--accent-pro); color: white; }
#vision-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 10; display: none; justify-content: center; align-items: center; }
#vision-video { width: 100%; max-width: 80%; max-height: 80%; border-radius: 10px; }
#vision-close-btn { position: absolute; top: 20px; right: 20px; font-size: 2rem; color: white; background: transparent; border: none; cursor: pointer; }
#voice-controls { display: flex; flex-direction: column; align-items: stretch; gap: 10px; padding: 10px 1rem; }
#voice-visualizer { width: 100%; height: 80px; margin-bottom: 10px; }
.voice-carousel-container { width: 100%; overflow: hidden; position: relative; }
.voice-carousel { display: flex; gap: 10px; padding: 10px 0; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; -ms-overflow-style: none; }
.voice-carousel::-webkit-scrollbar { display: none; }
.voice-card { flex: 0 0 130px; padding: 15px 10px; border: 1px solid var(--border-color); background-color: var(--bg-tertiary); border-radius: 12px; text-align: center; cursor: pointer; transition: all 0.3s ease; scroll-snap-align: center; }
.voice-card h4 { color: var(--text-primary); font-size: 1rem; margin-bottom: 5px; pointer-events: none; }
.voice-card p { color: var(--text-secondary); font-size: 0.8rem; margin: 0; pointer-events: none; }
.voice-card:hover { border-color: rgba(255, 255, 255, 0.5); }
.voice-card.active { border-color: var(--accent-primary); background-color: var(--accent-primary); color: white; transform: scale(1.05); }
.voice-card.active h4, .voice-card.active p { color: white; }

/* =================================== */
/* --- 5. TOOLS & PRO PAGE STYLES --- */
/* =================================== */
#tools-view { padding: 2rem; overflow-y: auto; display: none; flex-direction: column; gap: 2rem; }
.tool-container { padding: 2rem; background: var(--bg-secondary); border-radius: 15px; border: 1px solid var(--border-color); }
.tool-container.pro-feature.disabled { opacity: 0.5; pointer-events: none; }
.tool-container h2 { margin-bottom: 0.5rem; display: flex; align-items: center; gap: 10px; }
.tool-container p { color: var(--text-secondary); margin-bottom: 1.5rem; }
.tool-button, .tool-button-primary { padding: 0.8rem 1.5rem; border: 1px solid var(--border-color); background-color: var(--bg-tertiary); color: var(--text-primary); border-radius: 8px; cursor: pointer; transition: background-color 0.2s; }
.tool-button:hover { background-color: #3a3a3a; }
.tool-button-primary { background-color: var(--accent-primary); border-color: var(--accent-primary); color: white; }
.tool-button-primary:hover { background-color: #0069d9; }
.tool-button-primary:disabled { background-color: #555; border-color: #555; cursor: not-allowed; }
.upload-box { border: 2px dashed var(--border-color); border-radius: 10px; padding: 2rem; text-align: center; margin: 1.5rem 0; transition: border-color 0.2s; }
.upload-box:hover { border-color: var(--accent-primary); }
#file-name-display, #kb-file-name-display { margin-top: 1rem; color: var(--text-secondary); font-style: italic; }
#image-prompt-input, #video-idea-input, #music-prompt-input, #kb-name-input { width: 100%; min-height: 80px; padding: 1rem; border-radius: 8px; border: 1px solid var(--border-color); background-color: var(--bg-primary); color: var(--text-primary); font-size: 1rem; resize: vertical; margin-bottom: 1rem; }
#kb-name-input { min-height: auto; }
.image-result-container, .video-result-container { margin-top: 2rem; padding: 1rem; border: 1px solid var(--border-color); border-radius: 10px; text-align: center; background-color: #000; min-height: 150px; display: flex; justify-content: center; align-items: center; }
#generated-image, .scene-card video { max-width: 100%; height: auto; border-radius: 8px; }
.download-button { display: inline-block; margin-top: 1rem; padding: 0.8rem 1.5rem; background-color: var(--success-color); color: white; text-decoration: none; border-radius: 8px; transition: background-color 0.3s; }
.download-button:hover { opacity: 0.9; }
.pro-page-container { display: none; justify-content: center; align-items: center; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.5); z-index: 200; }
.pro-card .gradient-text { background: linear-gradient(90deg, #e0e0e0, #ffffff, #e0e0e0); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.features-list { list-style: none; margin: 2rem 0; text-align: left; }
.features-list li {
    display: flex;
    align-items: center;
    margin-bottom: 1.2rem;
    font-size: 0.95rem;
    transition: transform 0.2s ease-in-out;
}
.features-list li:hover {
    transform: translateX(5px); /* Slightly move on hover */
}
.features-list li:hover .checkmark {
    transform: scale(1.2); /* Make the checkmark pop */
}
.features-list .checkmark {
    transition: transform 0.2s ease-in-out;
}
.features-list .checkmark { color: var(--success-color); font-weight: bold; margin-right: 1rem; background: rgba(76, 175, 80, 0.1); border-radius: 50%; width: 24px; height: 24px; display: inline-flex; justify-content: center; align-items: center; }
.price-display { font-size: 2.5rem; font-weight: 600; color: #fff; margin-bottom: 1.5rem; }
.price-display .price-period { font-size: 1rem; font-weight: 400; color: var(--text-secondary); }
.pro-button { width: 100%; padding: 1rem; border: none; border-radius: 10px; font-size: 1.1rem; font-weight: 600; cursor: pointer; background: var(--accent-primary); color: white; transition: all 0.3s ease; box-shadow: 0 4px 15px rgba(0, 123, 255, 0.4); }
.pro-button:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0, 123, 255, 0.6); }
.script-area { margin-top: 2rem; display: none; flex-direction: column; gap: 1.5rem; }
.scene-card { background-color: var(--bg-tertiary); border: 1px solid var(--border-color); border-radius: 10px; padding: 1.5rem; }
.scene-card h4 { margin-bottom: 0.5rem; }
.scene-card .status-text { color: var(--text-secondary); }
.prompt-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 1rem; }
.image-upload-container { margin: 1rem 0; text-align: center; }
.image-preview { max-width: 100px; max-height: 100px; border-radius: 8px; margin-top: 10px; border: 1px solid var(--border-color); }
#assembly-container, #soundtrack-container { margin-top: 2rem; padding-top: 2rem; border-top: 1px solid var(--border-color); }
#assembly-progress { margin-top: 1rem; padding: 1rem; background-color: var(--bg-primary); border: 1px solid var(--border-color); border-radius: 8px; max-height: 200px; overflow-y: auto; font-family: 'Courier New', Courier, monospace; }
#assembly-log { font-size: 0.8rem; color: var(--text-secondary); white-space: pre-wrap; word-wrap: break-word; }
#kb-selector-container { margin-left: 10px; }
.kb-create-section { display: flex; gap: 10px; margin-bottom: 2rem; }
#kb-list-container ul { list-style: none; padding: 0; }
#kb-list-container li { background-color: var(--bg-tertiary); padding: 1rem; border-radius: 8px; margin-bottom: 10px; cursor: pointer; border: 1px solid transparent; transition: all 0.2s ease; }
#kb-list-container li:hover { border-color: var(--accent-primary); }
#kb-list-container li.active { border-color: var(--accent-primary); box-shadow: 0 0 10px var(--accent-primary); }
#kb-upload-section { margin-top: 2rem; border-top: 1px solid var(--border-color); padding-top: 2rem; }
/* --- Markdown Content Styles --- */
.message-content {
    white-space: pre-wrap;
}
.message-content p {
    margin-bottom: 1rem;
}
.message-content p:last-child {
    margin-bottom: 0;
}
.message-content h1, .message-content h2, .message-content h3 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}
.message-content ul, .message-content ol {
    padding-left: 2rem;
    margin-bottom: 1rem;
}
.message-content code:not(pre code) {
    background-color: var(--bg-tertiary);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
}
.message-content pre {
    background-color: #0d1117; /* GitHub dark color */
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1rem;
}
.message-content pre code {
    background-color: transparent;
    padding: 0;
}
.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}
.message-content th, .message-content td {
    border: 1px solid var(--border-color);
    padding: 0.8rem;
    text-align: left;
}
.message-content th {
    background-color: var(--bg-tertiary);
}
.message-content blockquote {
    border-left: 4px solid var(--border-color);
    padding-left: 1rem;
    margin-left: 0;
    color: var(--text-secondary);
    font-style: italic;
}

/* --- Platform-Specific Styles --- */

/* Example: Use native system fonts for a more integrated feel */
body.ios {
    font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
}

body.android {
    font-family: 'Roboto', sans-serif;
}

/* Example: Make scrollbars thinner on desktop */
body.desktop ::-webkit-scrollbar {
    width: 6px;
}
body.desktop ::-webkit-scrollbar-thumb {
    background-color: #444;
}

/* Example: Slightly different button style on iOS */
body.ios .auth-button {
    border-radius: 10px;
}

/* --- Pro Toast Notification Styles --- */
.toast {
    position: fixed;
    bottom: -100px; /* Initially hidden below the screen */
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--accent-pro);
    color: white;
    padding: 16px 24px;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    transition: bottom 0.5s ease-in-out;
}
.toast.show {
    bottom: 30px; /* Slide in from the bottom */
}
.toast a {
    color: white;
    font-weight: bold;
    text-decoration: underline;
}


