/* ====================================================================
   RohanGPT — Grok.com UI Clone Edition (Pure Jet-Black Theme)
   High-Contrast Matte Dark Layers, Sharp Outlines, and Grok Typography
   ==================================================================== */

:root {
    /* Pure Black & Slate Matte Color Space */
    --bg-primary: #000000;
    --bg-secondary: #09090b;
    --bg-tertiary: #18181b;
    --border-thin: #27272a;
    --border-focus: #52525b;
    
    /* Grok Accents */
    --accent-color: #ffffff;
    --accent-hover: #e4e4e7;
    --accent-blue: #3b82f6;
    --accent-orange: #f97316;
    
    /* Text Weights */
    --text-primary: #fafafa;
    --text-secondary: #d4d4d8;
    --text-tertiary: #71717a;
    --danger: #ef4444;
    --success: #22c55e;
    
    /* Structural Rules */
    --sidebar-width: 260px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    letter-spacing: -0.2px;
}

/* ========== APP CONTAINER LAYOUT ========== */

.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
}

/* ========== LEFT COLLAPSIBLE NAVIGATION SIDEBAR (GROK BLACK) ========== */

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-thin);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 10;
    transition: var(--transition);
}

.sidebar-header {
    padding: 24px 20px 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-symbol {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
}

.logo-name {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.menu-close-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
    transition: var(--transition);
}

.menu-close-btn:hover {
    color: var(--text-primary);
}

/* New Chat Button (Minimalist Matte Border) */
.new-chat-btn {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-thin);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Space Grotesk', sans-serif;
    cursor: pointer;
    margin: 8px 16px 16px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    transition: var(--transition);
}

.new-chat-btn:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--border-focus);
}

.sidebar-search {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    padding: 10px 14px;
    margin: 0 16px 16px 16px;
    max-width: 280px;
    transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}

.sidebar-search:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.14);
    transform: translateY(-1px);
}

.sidebar-search input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 13px;
    letter-spacing: -0.2px;
    padding: 0;
}

.sidebar-search input::placeholder {
    color: var(--text-tertiary);
}

.search-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    font-size: 14px;
}

/* History list scroll pane */
.history-section {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
}

.section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-tertiary);
    margin-bottom: 12px;
    padding-left: 12px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.empty-history-text {
    font-size: 12px;
    color: var(--text-tertiary);
    text-align: center;
    margin-top: 16px;
}

.history-item {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition);
}

.history-item:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.history-item.active {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    font-weight: 600;
}

.delete-thread-btn {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 12px;
    opacity: 0;
    transition: var(--transition);
}

.history-item:hover .delete-thread-btn {
    opacity: 1;
}

.delete-thread-btn:hover {
    color: var(--danger);
}

/* Sidebar footer config options */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-thin);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.footer-action-btn {
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    text-align: left;
    color: var(--text-secondary);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition);
}

.footer-action-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ========== MAIN CHAT CANVAS ========== */

.main-canvas {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    background-color: var(--bg-primary);
}

/* Header Row (Matte Black, clean) */
.header {
    height: 64px;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-thin);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--bg-primary);
    z-index: 5;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.hamburger-menu-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    padding: 6px;
}

/* Model choice Select styling */
.model-selector-container select {
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    outline: none;
}

.model-selector-container select option {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}


.generative-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.generative-badge.active {
    background: rgba(59, 130, 246, 0.14);
    border-color: rgba(59, 130, 246, 0.24);
    color: #ffffff;
    transform: translateY(-1px);
}

.chat-history-container {
    display: flex;
    flex-direction: column;
    gap: 32px;
    padding-bottom: 160px; /* Space for input */
    scroll-behavior: smooth;
}

/* ========== WORKSPACE CHAT CANVAS ========== */

.chat-workspace {
    flex: 1;
    overflow-y: auto;
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
}

.chat-workspace::-webkit-scrollbar {
    width: 4px;
}
.chat-workspace::-webkit-scrollbar-track {
    background: transparent;
}
.chat-workspace::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 10px;
}

/* Grok Welcome Overlay */
.welcome-container {
    margin: auto 0;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 40px;
}

.large-grok-logo {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 64px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: -16px;
}

.welcome-header h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Sharp, Minimalist Automation Cards */
.automation-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    max-width: 680px;
    margin: 0 auto;
    width: 100%;
}

.automation-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-thin);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    text-align: left;
    transition: var(--transition);
}

.automation-card:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--border-focus);
    transform: translateY(-1px);
}

.card-icon {
    font-size: 22px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-content h3 {
    font-size: 14px;
    font-weight: 600;
    font-family: 'Space Grotesk', sans-serif;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.card-content p {
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.4;
}

/* ========== ACTIVE CHAT STREAM (GROK LAYOUT) ========== */

.chat-history-container {
    display: flex;
    flex-direction: column;
    gap: 28px;
    padding-bottom: 160px; /* Space for input */
    scroll-behavior: smooth;
    align-items: flex-start;
    max-width: 100%;
}

.chat-message {
    display: flex;
    width: 100%;
}

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

.chat-message.bot-message {
    justify-content: flex-start;
}

.message-avatar {
    display: none; /* Hide avatars for pure clean minimalist Grok experience! */
}

/* Minimalist User Speech Capsule (Clean matte gray) */
.chat-message.user-message .message-bubble {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-thin);
    color: var(--text-primary);
    border-radius: var(--radius-lg);
    font-weight: 500;
    max-width: 80%;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
}

/* Completely borderless assistant layout */
.chat-message.bot-message {
    opacity: 0;
    transform: translateY(8px);
    animation: fadeInUp 0.28s ease forwards;
}

.chat-message.bot-message .message-bubble {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    border-radius: 18px;
    padding: 16px 20px;
    max-width: 80%;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-bubble {
    padding: 10px 14px;
    line-height: 1.65;
    font-size: 15px;
}

.message-bubble p {
    margin-bottom: 10px;
}
.message-bubble p:last-child {
    margin-bottom: 0;
}
.message-bubble strong {
    color: var(--text-primary);
    font-weight: 700;
}
.message-bubble em {
    color: var(--text-primary);
    font-weight: 600;
}
.message-bubble ul, .message-bubble ol {
    margin-left: 20px;
    margin-bottom: 12px;
}
.message-bubble li {
    margin-bottom: 6px;
}

/* Typing Cursor blink for streaming */
.typing-cursor {
    display: inline-block;
    width: 6px;
    height: 14px;
    background-color: var(--text-primary);
    margin-left: 4px;
    animation: cursorBlink 0.7s infinite;
    vertical-align: middle;
}

@keyframes cursorBlink {
    50% { opacity: 0; }
}

/* ========== FLOATING GROK BOX PILL ========== */

.input-bar-container {
    position: fixed;
    bottom: 18px;
    left: 18px;
    right: 18px;
    z-index: 20;
    pointer-events: none;
}

.grok-input-box {
    max-width: 980px;
    width: 100%;
    margin: 0 auto;
    background: rgba(236, 248, 255, 0.06);
    backdrop-filter: blur(28px);
    border: 1px solid rgba(164, 202, 254, 0.22);
    border-radius: 46px;
    padding: 16px 16px 14px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    align-items: stretch;
    box-shadow: 0 24px 50px rgba(59, 130, 246, 0.12);
    pointer-events: all;
}

.grok-input-box:focus-within {
    border-color: rgba(59, 130, 246, 0.35);
}

.grok-input-box textarea {
    width: 100%;
    min-height: 54px;
    max-height: 140px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 22px;
    outline: none;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.75;
    resize: none;
    padding: 12px 14px;
}

.grok-input-box textarea::placeholder {
    color: rgba(248, 250, 252, 0.55);
}

.input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.input-row textarea {
    flex: 1;
    min-height: 52px;
}

.input-controls-row {
    display: none;
}

.left-controls {
    display: none;
}

.control-btn {
    width: 44px;
    height: 44px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.control-btn:hover {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.18);
    transform: translateY(-1px);
}

.right-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.send-grok-btn {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    background: linear-gradient(135deg, #8b5cf6 0%, #22d3ee 100%);
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 12px 28px rgba(59, 130, 246, 0.18);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.send-grok-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 24px 60px rgba(14, 165, 233, 0.32);
}

.send-grok-btn:active {
    transform: scale(0.97);
}

.send-arrow {
    font-size: 18px;
    font-weight: 800;
}

.grok-footer-disclaimer {
    text-align: center;
    margin-top: 10px;
    color: rgba(248, 250, 252, 0.75);
    font-size: 12px;
    letter-spacing: 0.2px;
}

/* ========== SETTINGS DRAWER MODAL ========== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 1;
    transition: var(--transition);
}

.modal.hidden {
    display: none;
    opacity: 0;
}

.modal-content {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-thin);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 480px;
    padding: 32px;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
    animation: zoomIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes zoomIn {
    from { transform: scale(0.96); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 24px;
    cursor: pointer;
    transition: var(--transition);
}

.modal-close-btn:hover {
    color: var(--text-primary);
}

.modal-content h2 {
    font-size: 20px;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.setting-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-group label {
    font-size: 12px;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.setting-group input, .setting-group select, .setting-group textarea {
    width: 100%;
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-thin);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    outline: none;
    transition: var(--transition);
}

.setting-group input:focus, .setting-group select:focus, .setting-group textarea:focus {
    border-color: var(--border-focus);
}

.range-container {
    display: flex;
    align-items: center;
    gap: 14px;
}

.range-container input {
    flex: 1;
    padding: 0;
}

.save-settings-btn {
    background-color: var(--accent-color);
    color: var(--bg-primary);
    border: none;
    width: 100%;
    padding: 12px;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.save-settings-btn:hover {
    background-color: var(--accent-hover);
}

/* ========== MOBILE RESPONSIVE DRAWER OVERRIDES ========== */

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: -260px; /* Hide drawer off screen */
        height: 100vh;
        border-radius: 0;
    }

    .sidebar.active {
        left: 0; /* Slide drawer in */
    }

    .sidebar.active ~ .main-canvas {
        transform: translateX(260px);
    }

    .main-canvas {
        transition: transform 0.25s ease;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background-color: rgba(0, 0, 0, 0.8);
        backdrop-filter: blur(6px);
        z-index: 9;
    }

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

    .menu-close-btn {
        display: block;
    }

    .hamburger-menu-btn {
        display: block !important;
    }

    .automation-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .welcome-header h2 {
        font-size: 26px;
    }

    .header {
        padding: 0 20px;
    }

    .main-canvas {
        transition: transform var(--transition);
    }

    .sidebar.active ~ .main-canvas {
        transform: translateX(var(--sidebar-width));
    }

    .input-bar-container {
        left: 8px;
        right: 8px;
        bottom: 8px;
    }

    .grok-input-box {
        padding: 14px;
        grid-template-columns: 1fr;
        gap: 12px;
        width: calc(100vw - 16px);
        max-width: 100%;
    }

    .grok-input-box textarea {
        min-height: 48px;
        font-size: 15px;
        line-height: 1.7;
    }

    .input-controls-row {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        padding-top: 10px;
        border-top: 1px solid rgba(255, 255, 255, 0.06);
        margin-top: 10px;
    }

    .left-controls,
    .right-controls {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        gap: 10px;
    }

    .left-controls {
        flex-wrap: wrap;
    }

    .right-controls {
        flex-wrap: wrap;
    }

    .control-btn {
        width: 44px;
        height: 44px;
        border-radius: 14px;
    }

    .send-grok-btn {
        width: 52px;
        height: 52px;
        border-radius: 16px;
        flex-shrink: 0;
    }

    .grok-status-badge {
        font-size: 11px;
        padding: 8px 12px;
        white-space: normal;
        text-align: center;
        flex: 1;
        min-width: 0;
    }
}

/* Desktop Collapsible Sidebar transitions */
@media (min-width: 901px) {
    .app-container.sidebar-hidden .sidebar {
        margin-left: -260px; /* Slide off-canvas! */
    }
}


/* Global focus styling for high visibility/accessibility */
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 1.5px solid var(--border-focus) !important;
    outline-offset: 3px !important;
}

/* ========== LOGO FALLBACK IMAGE SWITCHING & RECREATION ANIMATIONS ========== */

.fallback-logo-img:not([style*="display: none"]) ~ .rohan-glow-svg {
    display: none !important;
}

@keyframes bounceGlow {
    0%, 100% {
        transform: translateY(0) scale(1);
        filter: drop-shadow(0 0 10px rgba(124, 58, 237, 0.3));
    }
    50% {
        transform: translateY(-6px) scale(1.03);
        filter: drop-shadow(0 0 22px rgba(6, 182, 212, 0.5));
    }
}

.logo-symbol-container svg {
    animation: sidebarPulseGlow 3.5s ease-in-out infinite;
}

@keyframes sidebarPulseGlow {
    0%, 100% {
        filter: drop-shadow(0 0 4px rgba(124, 58, 237, 0.25));
    }
    50% {
        filter: drop-shadow(0 0 10px rgba(6, 182, 212, 0.45));
    }
}
