/* =========================================================
PRASUN AI
Main Styles
========================================================= */

:root {
    --bg: #ffffff;
    --surface: #f7f7f8;
    --surface-hover: #eeeeee;

    --sidebar: #f7f7f8;

    --text: #1f1f1f;
    --text-secondary: #6b6b6b;
    --text-muted: #8b8b8b;

    --border: #e5e5e5;

    --accent: #111111;

    --user-message: #f4f4f4;

    --shadow:
        0 1px 3px rgba(0, 0, 0, 0.06),
        0 8px 24px rgba(0, 0, 0, 0.04);

    --sidebar-width: 280px;
    --composer-width: 760px;

    --radius-small: 10px;
    --radius-medium: 14px;
    --radius-large: 20px;

    --transition: 0.2s ease;
}

/* =========================================================
RESET
========================================================= */

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

html {
    height: 100%;
    font-size: 16px;
}

body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
    font: inherit;
}

button {
    border: 0;
    cursor: pointer;
}

a {
    color: inherit;
    text-decoration: none;
}

/* =========================================================
APP
========================================================= */

.app {
    width: 100%;
    height: 100vh;
    display: flex;
    background: var(--bg);
}

/* =========================================================
SIDEBAR
========================================================= */

.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    padding: 14px;
    z-index: 100;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.brand-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--accent);
    color: white;
    font-size: 16px;
}

.icon-button {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 18px;
    transition: var(--transition);
}

.icon-button:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.mobile-close {
    display: none;
}

/* =========================================================
NEW CHAT
========================================================= */

.new-chat-button {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 13px;
    border-radius: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    transition: var(--transition);
}

.new-chat-button:hover {
    background: var(--surface-hover);
}

.new-chat-icon {
    font-size: 19px;
    font-weight: 400;
}

/* =========================================================
CHAT SEARCH
========================================================= */

.chat-search {
    height: 40px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
}

.search-icon {
    color: var(--text-muted);
    font-size: 19px;
}

.chat-search input {
    min-width: 0;
    flex: 1;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: 13px;
}

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

.search-shortcut {
    color: var(--text-muted);
    font-size: 10px;
    white-space: nowrap;
}

/* =========================================================
HISTORY
========================================================= */

.history-container {
    flex: 1;
    overflow-y: auto;
    margin-top: 22px;
}

.history-section {
    margin-bottom: 22px;
}

.history-title {
    padding: 0 9px 7px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-item {
    width: 100%;
    padding: 9px 10px;
    text-align: left;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    transition: var(--transition);
}

.history-item:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.history-item.active {
    background: #e9e9e9;
    color: var(--text);
    font-weight: 500;
}

/* =========================================================
SIDEBAR BOTTOM
========================================================= */

.sidebar-bottom {
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.sidebar-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 10px;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    text-align: left;
    font-size: 13px;
    transition: var(--transition);
}

.sidebar-item:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 7px 5px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #222;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
}

.user-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-info strong {
    font-size: 12px;
}

.user-info span {
    color: var(--text-muted);
    font-size: 10px;
}

.profile-more {
    margin-left: auto;
    color: var(--text-muted);
}

/* =========================================================
MAIN
========================================================= */

.main {
    min-width: 0;
    flex: 1;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* =========================================================
TOPBAR
========================================================= */

.topbar {
    height: 60px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid transparent;
}

.menu-button {
    display: none;
}

.model-selector {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 9px;
    border-radius: 9px;
    background: transparent;
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    transition: var(--transition);
}

.model-selector:hover {
    background: var(--surface);
}

.model-badge {
    padding: 2px 5px;
    border-radius: 5px;
    background: #eeeeee;
    color: #666;
    font-size: 9px;
    font-weight: 700;
}

.chevron {
    color: var(--text-muted);
    font-size: 12px;
}

.topbar-actions {
    margin-left: auto;
}

/* =========================================================
CHAT AREA
========================================================= */

.chat-area {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    position: relative;
}

.welcome-screen {
    width: min(900px, calc(100% - 40px));
    min-height: 100%;
    margin: 0 auto;
    padding: 8vh 20px 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.welcome-icon {
    width: 54px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 22px;
    border-radius: 16px;
    background: var(--accent);
    color: white;
    font-size: 27px;
    box-shadow: var(--shadow);
}

.welcome-screen h1 {
    max-width: 700px;
    font-size: clamp(27px, 4vw, 40px);
    line-height: 1.15;
    letter-spacing: -1.3px;
    font-weight: 700;
}

.welcome-screen > p {
    max-width: 600px;
    margin-top: 15px;
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.6;
}

/* =========================================================
SUGGESTIONS
========================================================= */

.suggestions {
    width: min(700px, 100%);
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 35px;
}

.suggestion-card {
    min-height: 78px;
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 15px;
    text-align: left;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    line-height: 1.45;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.suggestion-card:hover {
    background: var(--surface);
    transform: translateY(-1px);
    box-shadow: 0 5px 18px rgba(0, 0, 0, 0.06);
}

.suggestion-icon {
    flex-shrink: 0;
    color: var(--text-secondary);
    font-size: 17px;
}

/* =========================================================
MESSAGES
========================================================= */

.messages {
    width: min(820px, calc(100% - 40px));
    margin: 0 auto;
    padding: 30px 0 150px;
}

.message {
    display: flex;
    margin-bottom: 28px;
}

.message.user {
    justify-content: flex-end;
}

.message-content {
    max-width: 75%;
    line-height: 1.65;
    font-size: 15px;
}

.message.user .message-content {
    padding: 11px 15px;
    border-radius: 18px 18px 5px 18px;
    background: var(--user-message);
}

.message.ai {
    justify-content: flex-start;
}

.ai-avatar {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    border-radius: 9px;
    background: var(--accent);
    color: white;
    font-size: 14px;
}

/* =========================================================
COMPOSER & ATTACHMENT PREVIEW
========================================================= */

.composer-wrapper {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 10px 20px 18px;
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0),
        rgba(255, 255, 255, 0.94) 20%,
        rgba(255, 255, 255, 1) 50%
    );
}

/* Attachment Preview UI */
.attachment-preview {
    width: min(var(--composer-width), calc(100% - 20px));
    margin: 0 auto 8px auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    font-size: 13px;
}

.attachment-preview[hidden] {
    display: none !important;
}

.attachment-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#attachmentName {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#attachmentSize {
    color: var(--text-muted);
    font-size: 11px;
}

.remove-attachment {
    background: transparent;
    color: var(--text-muted);
    font-size: 16px;
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
}

.remove-attachment:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.composer {
    width: min(var(--composer-width), calc(100% - 20px));
    margin: 0 auto;
    padding: 9px 10px 8px;
    border: 1px solid #d7d7d7;
    border-radius: 18px;
    background: var(--bg);
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.05), 0 8px 30px rgba(0, 0, 0, 0.06);
}

.composer-toolbar {
    display: flex;
    align-items: center;
}

.composer-tool {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 20px;
}

.composer-tool:hover {
    background: var(--surface);
    color: var(--text);
}

.composer textarea {
    width: 100%;
    min-height: 30px;
    max-height: 180px;
    resize: none;
    padding: 4px 5px 7px;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}

.composer textarea::placeholder {
    color: var(--text-muted);
}

.composer-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.composer-options {
    display: flex;
    align-items: center;
}

.composer-option {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 8px;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
}

.composer-option:hover {
    background: var(--surface);
    color: var(--text);
}

.send-button {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: #e5e5e5;
    color: #999;
    font-size: 18px;
    font-weight: 600;
    transition: var(--transition);
}

.send-button:not(:disabled) {
    background: var(--accent);
    color: white;
}

.send-button:not(:disabled):hover {
    transform: translateY(-1px);
}

.send-button:disabled {
    cursor: default;
}

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

/* =========================================================
DARK MODE
========================================================= */

body.dark {
    --bg: #212121;
    --surface: #2a2a2a;
    --surface-hover: #333333;
    --sidebar: #171717;
    --text: #eeeeee;
    --text-secondary: #b5b5b5;
    --text-muted: #858585;
    --border: #353535;
    --accent: #ffffff;
    --user-message: #303030;
}

body.dark .brand-icon {
    background: #fff;
    color: #111;
}

body.dark .user-avatar {
    background: #fff;
    color: #111;
}

body.dark .model-badge {
    background: #333;
    color: #aaa;
}

body.dark .history-item.active {
    background: #303030;
}

body.dark .composer-wrapper {
    background: linear-gradient(
        to bottom,
        rgba(33, 33, 33, 0),
        rgba(33, 33, 33, 0.94) 20%,
        rgba(33, 33, 33, 1) 50%
    );
}

body.dark .composer {
    border-color: #444;
}

body.dark .send-button {
    background: #444;
    color: #888;
}

body.dark .send-button:not(:disabled) {
    background: #fff;
    color: #111;
}

/* =========================================================
SCROLLBAR & SELECTION
========================================================= */

* {
    scrollbar-width: thin;
    scrollbar-color: #cfcfcf transparent;
}

body.dark * {
    scrollbar-color: #4a4a4a transparent;
}

::selection {
    background: #d8d8d8;
    color: #111;
}

body.dark ::selection {
    background: #555;
    color: #fff;
}
