/* ═══════════════════════════════════════════
   Arcai AI — Premium Dark Theme
   Mobile-first, responsive, glassmorphism
   ═══════════════════════════════════════════ */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #0f0f1a;
    /* Slightly darker */
    --bg-card: rgba(26, 26, 46, 0.6);
    /* More transparent */
    --bg-card-hover: rgba(34, 34, 64, 0.7);
    --bg-glass: rgba(10, 10, 15, 0.7);
    /* Darker glass */
    --bg-input: rgba(22, 22, 42, 0.5);

    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #606070;

    --accent: #6c5ce7;
    --accent-light: #a29bfe;
    --accent-glow: rgba(108, 92, 231, 0.5);
    /* Stronger glow */
    --gradient-1: linear-gradient(135deg, #6c5ce7, #00cec9);
    /* Cyberpunk gradient */
    --gradient-2: linear-gradient(135deg, #fd79a8, #e17055);
    --gradient-3: linear-gradient(135deg, #00cec9, #0984e3);

    --success: #00b894;
    --warning: #fdcb6e;
    --danger: #ff7675;

    --bubble-user: linear-gradient(135deg, #6c5ce7, #4834d4);
    --bubble-ai: rgba(30, 30, 56, 0.8);

    --radius-sm: 8px;
    --radius-md: 16px;
    /* Rounder */
    --radius-lg: 24px;
    --radius-xl: 32px;

    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 20px var(--accent-glow);

    --font: 'Inter', system-ui, sans-serif;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    font-family: var(--font);
    background: linear-gradient(-45deg, #050510, #1a1a2e, #101020, #0a0a15);
    background-size: 400% 400%;
    animation: gradientBG 20s ease infinite;
    color: var(--text-primary);
    height: 100%;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

body {
    display: flex;
    flex-direction: column;
}

/* ═══ SCROLLBAR ═══ */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

/* ═══ TOP BAR ═══ */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    z-index: 100;
    flex-shrink: 0;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.logo {
    font-size: 18px;
    font-weight: 700;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 12px;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.08);
    white-space: nowrap;
    cursor: pointer;
    transition: var(--transition);
}

.badge:hover {
    background: var(--bg-card-hover);
}

.mode-badge {
    border-color: var(--accent);
    color: var(--accent-light);
}

.icon-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: var(--transition);
}

.icon-btn:hover {
    background: var(--bg-card);
}

/* ═══ LIMITS BAR ═══ */
.limits-bar {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 6px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 12px;
    font-weight: 500;
    flex-shrink: 0;
}

.limit-item {
    color: var(--text-secondary);
}

.limit-item span {
    color: var(--accent-light);
    font-weight: 700;
}

/* ═══ CHAT AREA ═══ */
.chat-area,
.gallery-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    scroll-behavior: smooth;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 100%;
    justify-content: flex-end;
}

/* ═══ MESSAGE BUBBLES ═══ */
.message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: fadeSlideUp 0.3s ease;
}

.message.user {
    align-self: flex-end;
}

.message.assistant {
    align-self: flex-start;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
}

.message.user .message-bubble {
    background: var(--bubble-user);
    color: white;
    border-bottom-right-radius: 6px;
}

.message.assistant .message-bubble {
    background: var(--bubble-ai);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-bottom-left-radius: 6px;
}

.message-time {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
    padding: 0 4px;
}

.message.user .message-time {
    text-align: right;
}

.message-copy {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.3);
    border: none;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
    opacity: 0;
    transition: var(--transition);
}

.message-bubble:hover .message-copy {
    opacity: 1;
}

/* ═══ TYPING INDICATOR ═══ */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    animation: fadeIn 0.3s ease;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: typingBounce 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

.typing-text {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ═══ GALLERY ═══ */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.gallery-card {
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    animation: fadeSlideUp 0.3s ease;
}

.gallery-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
}

.gallery-card-footer {
    padding: 8px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gallery-card-prompt {
    font-size: 11px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.gallery-card-actions {
    display: flex;
    gap: 4px;
}

.gallery-card-actions button {
    background: var(--bg-input);
    border: none;
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.gallery-card-actions button:hover {
    background: var(--accent);
    color: white;
}

.video-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.video-card {
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    animation: fadeSlideUp 0.3s ease;
}

.video-card video {
    width: 100%;
    max-height: 300px;
    background: black;
}

.video-card-footer {
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ═══ BOTTOM BAR ═══ */
.bottom-bar {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding: 8px 12px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    flex-shrink: 0;
    z-index: 100;
}

.mode-tabs {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 8px;
}

.mode-tab {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    font-size: 18px;
    padding: 6px 24px;
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: var(--transition);
}

.mode-tab.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
}

.mode-tab:hover:not(.active) {
    background: var(--bg-card-hover);
}

.input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    width: 100%;
}

textarea {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    padding: 10px 16px;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    resize: none;
    outline: none;
    max-height: 120px;
    transition: var(--transition);
}

textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

textarea::placeholder {
    color: var(--text-muted);
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--gradient-1);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
    box-shadow: var(--shadow-glow);
}

.send-btn:hover {
    transform: scale(1.05);
}

.send-btn:active {
    transform: scale(0.95);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ═══ CHIPS ═══ */
.style-chips,
.aspect-chips {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
    flex-wrap: nowrap;
}

.style-chips::-webkit-scrollbar,
.aspect-chips::-webkit-scrollbar {
    display: none;
}

.chip {
    padding: 5px 12px;
    border-radius: var(--radius-xl);
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
}

.chip.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.chip:hover:not(.active) {
    background: var(--bg-card-hover);
}

.image-controls,
.video-controls {
    flex-direction: column;
}

/* ═══ MODALS ═══ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-bottom: none;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 12px;
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 1;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.close-btn {
    background: var(--bg-card);
    border: none;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.close-btn:hover {
    background: var(--danger);
    color: white;
}

.modal-body {
    padding: 0 20px 20px;
}

.modal-footer {
    padding: 12px 20px 20px;
}

/* ═══ CARDS ═══ */
.card-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.card-grid.mode-cards {
    grid-template-columns: repeat(3, 1fr);
}

.card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    padding: 16px 12px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.card:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.card.active {
    border-color: var(--accent);
    background: rgba(108, 92, 231, 0.15);
    box-shadow: var(--shadow-glow);
}

.card-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.card-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.card-desc {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.3;
}

/* ═══ ONBOARDING ═══ */
.onboarding-modal {
    border-radius: var(--radius-xl);
    margin: auto;
    max-height: 80vh;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.onboarding-slides {
    position: relative;
    min-height: 200px;
}

.slide {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    opacity: 0;
    transform: translateX(30px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.slide.active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.slide-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.slide h3 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.slide p {
    color: var(--text-secondary);
    font-size: 14px;
}

.slide-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.dot.active {
    background: var(--accent);
    width: 24px;
    border-radius: 4px;
}

/* ═══ SETTINGS ═══ */
.settings-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-primary);
    font-size: 14px;
    width: 100%;
    font-family: var(--font);
}

.settings-item:hover {
    background: var(--bg-card-hover);
}

.settings-value {
    color: var(--accent-light);
    font-weight: 500;
    font-size: 13px;
}

.settings-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 8px 0;
}

.limits-display {
    cursor: default;
}

.limits-detail {
    display: flex;
    gap: 12px;
    font-size: 13px;
}

.limits-detail span {
    color: var(--text-secondary);
}

/* ═══ LIMIT MODAL ═══ */
.limit-modal {
    border-radius: var(--radius-xl);
    margin: auto;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.limit-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

/* ═══ BUTTONS ═══ */
.btn {
    padding: 12px 24px;
    border-radius: var(--radius-md);
    border: none;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
    text-align: center;
}

.btn-primary {
    background: var(--gradient-1);
    color: white;
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-accent {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.btn-accent:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
}

/* ═══ TOAST ═══ */
.toast-container {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    width: 90%;
    max-width: 400px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    pointer-events: auto;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.toast.success {
    background: rgba(0, 184, 148, 0.9);
    color: white;
}

.toast.error {
    background: rgba(214, 48, 49, 0.9);
    color: white;
}

.toast.warning {
    background: rgba(253, 203, 110, 0.9);
    color: #333;
}

.toast.info {
    background: rgba(108, 92, 231, 0.9);
    color: white;
}

/* ═══ SKELETON ═══ */
.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

.skeleton-line {
    height: 14px;
    margin-bottom: 8px;
    border-radius: 6px;
}

.skeleton-line:last-child {
    width: 60%;
}

/* ═══ DATE SEPARATOR ═══ */
.date-separator {
    text-align: center;
    padding: 16px 0 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ═══ ANIMATIONS ═══ */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* ═══ RESPONSIVE ═══ */
@media (min-width: 768px) {
    .modal {
        border-radius: var(--radius-xl);
        margin: auto;
        max-width: 440px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    }

    .modal-overlay {
        align-items: center;
    }

    .gallery-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}