/* ──────────────────────────────────────────────────────────
   Grok Imagine Chat — Conversational CSS
   ChatGPT/Grok-style layout
   ────────────────────────────────────────────────────────── */

.chat-layout {
    display: flex;
    height: 100vh;
    background: #0d0d0d;
    color: var(--text-primary);
    overflow: hidden;
}

/* ─── Sidebar ────────────────────────────────────────── */
.chat-sidebar {
    width: 260px;
    background: #000;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 16px;
}

.btn-new-chat {
    width: 100%;
    justify-content: flex-start;
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
}

.btn-new-chat:hover {
    background: var(--bg-card-hover);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.history-group {
    font-size: 12px;
    color: var(--text-muted);
    padding: 12px 12px 8px;
    font-weight: 600;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.history-icon {
    flex-shrink: 0;
    opacity: 0.6;
    color: var(--accent-3);
}

.history-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.history-item.active {
    background: #202123;
    color: var(--text-primary);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.03);
}

.user-profile img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

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

.user-name {
    font-size: 13px;
    font-weight: 600;
}

.user-credits {
    font-size: 11px;
    color: var(--accent-3);
}

/* ─── Main Chat Area ─────────────────────────────────── */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: radial-gradient(circle at center, #1a1a1b 0%, #0d0d0d 100%);
}

.chat-header {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: rgba(13, 13, 13, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    z-index: 10;
}

.chat-title {
    font-size: 16px;
    font-weight: 600;
}

.credits-pill {
    padding: 6px 14px;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    color: var(--accent-3);
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 40px 24px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    scroll-behavior: smooth;
}

.empty-state {
    max-width: 720px;
    margin: 100px auto 0;
    text-align: center;
}

.empty-state h1 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 40px;
    background: linear-gradient(135deg, white, #a1a1aa);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.suggestion-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.suggestion {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.suggestion:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--accent-1);
}

.suggestion span {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.suggestion small {
    font-size: 11px;
    color: var(--text-muted);
}

/* ─── Message Bubbles ────────────────────────────────── */
.message {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.msg-user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.msg-ai .message-avatar {
    background: var(--accent-1);
    color: white;
}

.msg-user .message-avatar {
    background: #5436da;
}

.message-content {
    max-width: 85%;
    font-size: 16px;
    line-height: 1.6;
    color: #e5e5e5;
    word-wrap: break-word;
}

.msg-user .message-content {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 12px 16px;
    border-radius: 12px 12px 0 12px;
}

.msg-ai .message-content {
    padding: 4px 0; /* AI messages usually look cleaner without background or padding if no bubble */
}

.ai-media {
    margin-top: 16px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
}

.ai-media img, .ai-media video {
    width: 100%;
    max-height: 500px;
    object-fit: contain;
    display: block;
}

/* ─── Input Area ────────────────────────────────────── */
.chat-input-wrapper {
    width: 100%;
    max-width: 800px;
    margin: 0 auto 24px;
    padding: 0 24px;
    position: sticky;
    bottom: 24px;
}

.chat-controls {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    background: rgba(20, 20, 20, 0.6);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.chat-cost-badge {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-3);
    border: 1px solid rgba(99, 102, 241, 0.3);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.chat-cost-badge span:last-child {
    font-size: 10px;
    text-transform: uppercase;
    opacity: 0.7;
    margin-left: 2px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-group label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.control-group select {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    outline: none;
}

.input-area {
    background: #2f2f2f;
    border: 1px solid #444;
    border-radius: 24px;
    padding: 10px 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.input-container {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.btn-attach, .btn-send {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.btn-attach:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.btn-send {
    background: var(--accent-1);
    color: white;
}

.btn-send:hover {
    background: var(--accent-2);
}

#chatInput {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    font-family: var(--font);
    font-size: 16px;
    padding: 6px 0;
    resize: none;
    outline: none;
    max-height: 200px;
}

.attachment-preview {
    margin-bottom: 10px;
    position: relative;
    width: 60px;
    height: 60px;
}

.attachment-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #444;
}

.remove-attachment {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #ff4d4d;
    color: white;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 12px;
    cursor: pointer;
}

.input-info {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* ─── Tablet/Mobile Chat Refinements ─────────────────── */
.mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    width: 40px;
    height: 40px;
}

@media (max-width: 768px) {
    .chat-sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        z-index: 100;
        box-shadow: 20px 0 50px rgba(0,0,0,0.5);
    }
    
    .chat-sidebar.active {
        transform: translateX(260px);
    }
    
    .mobile-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .messages-container {
        padding: 20px 16px;
    }

    .message {
        gap: 12px;
    }

    .chat-input-wrapper {
        padding: 0 12px;
        bottom: 12px;
    }

    .chat-controls {
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
        justify-content: flex-start;
        padding: 8px 12px;
        border-radius: 12px;
    }
    
    .control-group label {
        display: none; /* Hide labels on mobile to save space */
    }

    .input-area {
        border-radius: 18px;
    }
}

@media (max-width: 480px) {
    .empty-state h1 {
        font-size: 24px;
        margin-bottom: 24px;
    }

    .suggestion-grid {
        grid-template-columns: 1fr;
    }

    .suggestion {
        padding: 12px;
    }

    .chat-header {
        padding: 0 12px;
    }
}
/* ─── Modals & Overlays ──────────────────────────────── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: #1a1a1b;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    width: 100%;
    max-width: 480px;
    position: relative;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.show .modal {
    transform: scale(1);
}

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

.modal-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    text-align: center;
}

.modal-desc {
    color: var(--text-muted);
    text-align: center;
    font-size: 14px;
    margin-bottom: 24px;
}

/* ─── Toast Animations ───────────────────────────────── */
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast {
    animation: slideIn 0.3s ease-out;
}

/* ─── Shimmer / Skeleton Loader ───────────────────────── */
.skeleton-loader {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.shimmer {
    background: rgba(255, 255, 255, 0.08);
    background-image: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.18) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    background-repeat: no-repeat;
    background-size: 200% 100%;
    display: inline-block;
    position: relative;
    animation: shimmer 1.5s infinite linear;
    border-radius: 12px;
}

.shimmer-media {
    height: 180px;
    width: 100%;
}

.shimmer-text {
    height: 14px;
    width: 90%;
}

.shimmer-text-short {
    height: 14px;
    width: 60%;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.ai-media.processing {
    background: transparent;
    border: none;
    padding: 0;
    min-height: 200px;
}

/* ─── Message Actions ────────────────────────────────── */
.message-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    opacity: 0;
    transition: opacity 0.3s;
}

.message:hover .message-actions {
    opacity: 1;
}

.action-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--accent-3);
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    background: var(--accent-1);
    color: white;
    border-color: var(--accent-1);
    transform: translateY(-2px);
}

/* ─── Navbar & Sidebar Enhancements ─────────────────── */
.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-credits {
    display: flex;
    align-items: center;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2px 2px 2px 12px;
    gap: 10px;
}

.credits-badge {
    font-size: 13px;
    font-weight: 600;
}

.btn-buy-nav {
    background: var(--accent-1);
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-buy-nav:hover { background: var(--accent-2); }

.btn-gift-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-gift-nav:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: var(--accent-1);
}

.btn-gift-sidebar:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: var(--accent-1) !important;
}

.nav-btn-icon {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.2s;
}

.nav-btn-icon:hover {
    background: var(--bg-surface);
    color: white;
}

/* ─── Showcase Modal ────────────────────────────────── */
.showcase-grid {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.showcase-item {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
}

.showcase-item:hover {
    transform: translateY(-4px);
    border-color: var(--accent-1);
}

.showcase-thumb {
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    position: relative;
}

.showcase-thumb img, .showcase-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.showcase-info {
    padding: 12px;
}

.showcase-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.showcase-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    border-bottom: 2px solid transparent;
}

.tab-btn.active {
    color: var(--accent-1);
    border-bottom-color: var(--accent-1);
}

/* User Input Media (Thumbnail) */
.user-media {
    margin-top: 8px;
    max-width: 120px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.user-media:hover {
    transform: scale(1.05);
    border-color: var(--primary);
    box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}

.user-media img {
    width: 100%;
    height: auto;
    display: block;
}

/* ─── Referral Modal ──────────────────────────────────── */
.referral-modal {
    text-align: center;
}

.modal-icon {
    margin: 0 auto 20px;
    width: 64px;
    height: 64px;
    background: rgba(245, 158, 11, 0.1);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.referral-box {
    display: flex;
    gap: 8px;
    margin: 20px 0 24px;
}

.referral-box input {
    flex: 1;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    color: white;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.referral-box input:focus {
    border-color: var(--accent-1);
}

.social-share {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 32px;
}

.share-btn {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, filter 0.2s;
    border: none;
}

.share-btn:hover {
    transform: translateY(-4px);
    filter: brightness(1.1);
}

.referral-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.ref-stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: white;
    margin-bottom: 4px;
}

.ref-stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
