/* ========================================
   Rorak V1 — Dark Premium UI
   ======================================== */


/* ── Reset & Base ── */

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

html, body {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 Helvetica, Arial, sans-serif;
    background: #0a0a0a;
    color: #e0e0e0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}


/* ── App Shell ── */

.app {
    display: flex;
    flex-direction: column;
    height: 100%;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    position: relative;
}


/* ── Disclaimer Banner ── */

.disclaimer-bar {
    flex-shrink: 0;
    text-align: center;
    font-size: 12px;
    color: #888;
    padding: 8px 16px;
    background: #0a0a0a;
    border-bottom: 1px solid #1a1a1a;
    letter-spacing: 0.01em;
}


/* ── App Body (sidebar + main) ── */

.app-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    overflow: hidden;
    position: relative;
}


/* ── Sidebar Panel ── */

.sidebar {
    width: 260px;
    min-width: 260px;
    background: #0e0e0e;
    border-right: 1px solid #1a1a1a;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 24px 16px 16px;
    z-index: 100;
}

.sidebar-top {
    display: flex;
    flex-direction: column;
}

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    padding: 0 4px;
}

.brand-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-sidebar-close {
    display: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #888;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.15s ease;
}

.btn-sidebar-close svg {
    width: 18px;
    height: 18px;
}

.btn-sidebar-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.brand-logo {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    object-fit: cover;
}

.brand-text {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    letter-spacing: -0.02em;
}

/* Navigation */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.8);
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-weight: 500;
}

.nav-item.disabled {
    cursor: default;
    opacity: 0.4;
    pointer-events: none;
}

.nav-badge {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    font-weight: 400;
    margin-left: auto;
}

/* Sidebar bottom */
.sidebar-bottom {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sidebar-tagline {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 12px;
    background: #1a1a1a;
    border-radius: 12px;
    font-size: 12px;
    color: #999;
    line-height: 1.5;
}

.tagline-icon {
    width: 18px;
    height: 18px;
    min-width: 18px;
    color: #888;
    margin-top: 1px;
}

.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 4px 8px;
}

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


/* ── Mobile Menu Toggle ── */

.menu-toggle {
    display: none;
    position: fixed;
    top: 10px;
    left: 12px;
    z-index: 100;
    width: 36px;
    height: 36px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px;
}

.menu-toggle span {
    display: block;
    width: 16px;
    height: 1.5px;
    background: #fff;
    border-radius: 1px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 250;
    backdrop-filter: blur(3px);
}

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


/* ── Main Area ── */

.main {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background: #111;
    position: relative;
}

/* ── Centered Empty Landing State ── */
.main.is-empty {
    justify-content: center;
    align-items: center;
    min-height: 0;
}

.main.is-empty .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin-bottom: 24px;
    padding: 0 20px;
    flex-shrink: 0;
}

.main.is-empty .empty-title {
    font-size: 32px;
    font-weight: 600;
    color: #f5f5f5;
    letter-spacing: -0.025em;
}

.main.is-empty .chat-messages {
    display: none;
}

.main.is-empty .input-area {
    max-width: 740px;
    width: 100%;
    padding: 0 20px;
    margin: 0 auto;
    flex-shrink: 0;
}

.main.is-empty .input-bar {
    background: #212121;
    border: 1px solid #323232;
    border-radius: 30px;
    padding: 6px 8px 6px 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    transition: all 0.2s ease;
}

.main.is-empty .input-bar:focus-within {
    border-color: #4a4a4a;
    background: #252525;
    box-shadow: 0 10px 38px rgba(0, 0, 0, 0.65);
}


/* ── Active Chat State ── */
.main:not(.is-empty) .empty-state {
    display: none;
}

.main:not(.is-empty) .chat-messages {
    display: block;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    padding: 28px 32px 16px;
}

.main:not(.is-empty) .input-area {
    flex-shrink: 0;
    padding: 0 32px 20px;
    width: 100%;
    max-width: 820px;
    margin: 0 auto;
}

.main:not(.is-empty) .input-bar {
    display: flex;
    align-items: center;
    border: 1px solid #2a2a2a;
    border-radius: 28px;
    padding: 4px 8px 4px 10px;
    background: #1a1a1a;
    transition: border-color 0.15s ease;
}

.main:not(.is-empty) .input-bar:focus-within {
    border-color: #444;
}


/* ── Chat Messages Scroll & Layout ── */

/* Minimal dark scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 2px;
}

/* Message layout */
.message {
    max-width: 780px;
    margin-bottom: 28px;
}

.message-user {
    margin-left: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.message-assistant {
    margin-right: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

/* Labels */
.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #222;
    border: 1px solid #333;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #888;
    font-weight: 500;
}

/* Content */
.message-content {
    font-size: 14.5px;
    line-height: 1.7;
    word-wrap: break-word;
}

.message-user .message-content {
    background: #1e1e1e;
    border: 1px solid #2a2a2a;
    color: #ddd;
    padding: 12px 18px;
    border-radius: 18px 18px 4px 18px;
    max-width: 600px;
}

.message-assistant .message-content {
    background: #1a1a1a;
    border: 1px solid #252525;
    color: #ccc;
    padding: 18px 22px;
    border-radius: 4px 18px 18px 18px;
    max-width: 700px;
}

.message-assistant .message-content strong {
    color: #fff;
    font-weight: 600;
}

/* Message footer (timestamp + copy) */
.message-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
    padding-right: 4px;
}

.message-time {
    font-size: 11px;
    color: #555;
}

.btn-copy {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: #555;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: color 0.15s ease, background 0.15s ease;
    padding: 0;
}

.btn-copy svg {
    width: 14px;
    height: 14px;
}

.btn-copy:hover {
    color: #aaa;
    background: #222;
}

.btn-copy.copied {
    color: #6b7;
}


/* ── Loading Dots ── */

.loading-dots {
    display: inline-flex;
    gap: 5px;
    padding: 12px 0;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    background: #555;
    border-radius: 50%;
    animation: dotPulse 1.2s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotPulse {
    0%, 80%, 100% {
        opacity: 0.3;
        transform: scale(0.85);
    }
    40% {
        opacity: 1;
        transform: scale(1);
    }
}


/* ── Input Bar Controls & Buttons ── */

.input-bar {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-upload {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #9e9e9e;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
    padding: 0;
}

.btn-upload svg {
    width: 18px;
    height: 18px;
}

.btn-upload:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.btn-upload:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.chat-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    background: transparent;
    color: #f3f3f3;
    padding: 10px 10px;
    font-family: inherit;
    min-width: 0;
}

.chat-input::placeholder {
    color: #777;
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.btn-grounded-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #b5b5b5;
    font-size: 11.5px;
    font-weight: 500;
    cursor: default;
    user-select: none;
}

.btn-grounded-pill svg {
    width: 13px;
    height: 13px;
    color: #60a5fa;
}

.btn-send {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    border: none;
    background: #ffffff;
    color: #111111;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, transform 0.15s ease;
    padding: 0;
}

.btn-send svg {
    width: 16px;
    height: 16px;
}

.btn-send:hover {
    background: #e5e5e5;
    transform: scale(1.04);
}

.btn-send:disabled {
    background: #2e2e2e;
    color: #555;
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}


/* ── Upload Indicator ── */

.upload-indicator {
    display: none;
    margin-bottom: 10px;
    padding-left: 8px;
}

.upload-indicator.active {
    display: flex;
    align-items: center;
}

.upload-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 16px;
    font-size: 13px;
    color: #999;
}

.upload-chip-remove {
    cursor: pointer;
    font-size: 15px;
    color: #666;
    line-height: 1;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    transition: color 0.15s ease;
}

.upload-chip-remove:hover {
    color: #ccc;
}


/* ── Notifications ── */

.notification {
    display: none;
    margin-bottom: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.4;
    background: #1a1a1a;
    color: #888;
    border: 1px solid #2a2a2a;
}

.notification.active {
    display: block;
}


/* ── Shake Animation ── */

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-3px); }
    40% { transform: translateX(3px); }
    60% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
}

.shake {
    animation: shake 0.35s ease;
}


/* ── Responsive — Tablet & Below ── */

@media (max-width: 768px) {
    .menu-toggle {
        display: flex;
    }

    .btn-sidebar-close {
        display: flex;
    }

    .sidebar {
        position: fixed;
        left: -290px;
        top: 0;
        bottom: 0;
        width: 280px;
        min-width: 280px;
        z-index: 300;
        background: #0e0e0e;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.85);
        transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.65);
        z-index: 250;
        backdrop-filter: blur(3px);
    }

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

    .main.is-empty .empty-title {
        font-size: 26px;
    }

    .main.is-empty .input-area {
        padding: 0 16px;
    }

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

    .input-area {
        padding: 0 16px 16px;
    }

    .message {
        max-width: 100%;
    }

    .message-user .message-content,
    .message-assistant .message-content {
        max-width: 100%;
    }
}


/* ── Responsive — Phone ── */

@media (max-width: 480px) {
    .disclaimer-bar {
        font-size: 11px;
        padding: 6px 12px;
    }

    .empty-title {
        font-size: 26px;
    }

    .empty-tagline {
        font-size: 14px;
    }

    .empty-description {
        font-size: 13px;
    }

    .chat-input {
        font-size: 16px;
    }

    .input-area {
        padding: 0 10px 10px;
    }

    .chat-messages {
        padding: 56px 14px 12px;
    }

    .message-assistant .message-content {
        padding: 14px 16px;
    }
}


/* ── Markdown Rich Content Styling ── */

.markdown-body {
    word-break: break-word;
}

.markdown-body p {
    margin-bottom: 10px;
    line-height: 1.65;
}

.markdown-body p:last-child {
    margin-bottom: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    color: #fff;
    margin-top: 14px;
    margin-bottom: 8px;
    font-weight: 600;
    line-height: 1.4;
}

.markdown-body h1 { font-size: 1.25rem; }
.markdown-body h2 { font-size: 1.15rem; }
.markdown-body h3 { font-size: 1.05rem; }
.markdown-body h4 { font-size: 0.95rem; }

.markdown-body ul,
.markdown-body ol {
    margin: 8px 0 10px 22px;
    padding-left: 2px;
}

.markdown-body li {
    margin-bottom: 4px;
    line-height: 1.6;
}

.markdown-body blockquote {
    border-left: 3px solid #3b82f6;
    padding-left: 12px;
    margin: 12px 0;
    color: #999;
    font-style: italic;
    background: rgba(59, 130, 246, 0.05);
    border-radius: 0 6px 6px 0;
    padding: 8px 12px;
}

.markdown-body code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12.5px;
    background: rgba(255, 255, 255, 0.1);
    color: #f3f3f3;
    padding: 2px 6px;
    border-radius: 4px;
}

.markdown-body pre {
    background: #0d0d0d;
    border: 1px solid #282828;
    border-radius: 8px;
    padding: 12px 14px;
    overflow-x: auto;
    margin: 12px 0;
    line-height: 1.5;
}

.markdown-body pre code {
    background: transparent;
    padding: 0;
    border-radius: 0;
    color: #e0e0e0;
    font-size: 13px;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 14px 0;
    font-size: 13.5px;
    overflow-x: auto;
    display: block;
}

.markdown-body th,
.markdown-body td {
    border: 1px solid #333;
    padding: 8px 12px;
    text-align: left;
}

.markdown-body th {
    background: #252525;
    color: #fff;
    font-weight: 600;
}

.markdown-body tr:nth-child(even) {
    background: #181818;
}

.markdown-body a {
    color: #60a5fa;
    text-decoration: underline;
}

.markdown-body a:hover {
    color: #93c5fd;
}

.markdown-body hr {
    border: 0;
    height: 1px;
    background: #282828;
    margin: 16px 0;
}
