/* =========================================
   AI Playground Workspace Design System
   Follows @docs/ standards for consistency
   ========================================= */

/* =========================================
   Workspace Layout Foundation
   ========================================= */

.workspace-container {
    display: flex;
    height: calc(100vh - 70px); /* Account for header */
    background: var(--gradient-primary); /* Use the magical gradient */
    margin-top: 0;
}

/* =========================================
   Panel System - Consistent depth hierarchy
   ========================================= */

.panel {
    background: var(--color-surface-card);
    border-radius: var(--radius-xl); /* 16px */
    box-shadow: var(--shadow-card);
}

.panel-raised {
    background: var(--color-surface-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-thick);
}

.panel-flat {
    background: var(--color-surface-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border-subtle);
}

.panel-inset {
    background: var(--color-surface-subtle);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border-subtle);
}

/* =========================================
   Sidebar Component - Using design tokens
   ========================================= */

.workspace-sidebar {
    width: 280px;
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.sidebar-section {
    background: var(--color-surface-card);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
    box-shadow: var(--shadow-card);
    height: 100%;
    display: flex;
    flex-direction: column;
}


/* =========================================
   Navigation System - Consistent buttons
   ========================================= */

.nav-section {
    padding: var(--space-4);
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.nav-title {
    font-family: var(--font-family-accent);
    font-size: 0.75rem;
    font-weight: var(--font-weight-bold);
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-3);
}

.nav-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    list-style: none;
    margin: 0;
    padding: 0;
}

/* =========================================
   Button System - Following design standards
   ========================================= */

.btn-nav {
    width: 100%;
    min-height: 44px; /* Touch-friendly */
    background: transparent;
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    padding: var(--space-3) var(--space-4);
    font-family: var(--font-family-interface);
    font-size: 0.875rem;
    font-weight: var(--font-weight-medium);
    color: var(--color-text-primary);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    text-align: left;
}

.btn-nav:hover {
    background: var(--color-surface-subtle);
    transform: translateY(-2px);
    box-shadow: var(--shadow-thin);
}

.btn-nav.active {
    background: var(--color-brand-500);
    color: white;
    border-color: var(--color-brand-500);
    box-shadow: var(--shadow-chunky);
}

.btn-nav.active:hover {
    background: var(--color-brand-600);
    transform: translateY(-1px);
    box-shadow: var(--shadow-thick);
}

.btn-nav-icon {
    font-size: 1.25rem;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-nav-label {
    flex: 1;
}

.btn-nav-badge {
    font-family: var(--font-family-accent);
    font-size: 0.625rem;
    font-weight: var(--font-weight-bold);
    background: var(--gradient-brand);
    color: white;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* =========================================
   Main Content Area
   ========================================= */

.workspace-main {
    flex: 1;
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    overflow: hidden;
}

/* =========================================
   Chat Interface - Clean design system
   ========================================= */

.chat-panel {
    flex: 1;
    background: var(--color-surface-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    padding: var(--space-6);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.message-bubble {
    max-width: 70%;
    animation: fadeInUp 0.3s ease;
}

.message-bubble.user {
    align-self: flex-end;
    margin-left: auto;
}

.message-bubble.ai {
    align-self: flex-start;
}

.message-content {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-xl);
    font-family: var(--font-family-interface);
    font-size: 0.875rem;
    line-height: 1.6;
}

.message-bubble.user .message-content {
    background: var(--gradient-brand);
    color: white;
    box-shadow: var(--shadow-card);
}

.message-bubble.ai .message-content {
    background: var(--color-surface-subtle);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border-subtle);
}

.message-model-tag {
    font-family: var(--font-family-accent);
    font-size: 0.625rem;
    color: var(--color-text-tertiary);
    margin-top: var(--space-1);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* =========================================
   Input Area - Consistent with design system
   ========================================= */

.chat-input-panel {
    padding: var(--space-5);
    background: var(--color-surface-subtle);
    border-top: 1px solid var(--color-border-subtle);
}

.input-group {
    display: flex;
    align-items: flex-end;
    gap: var(--space-3);
    background: var(--color-surface-card);
    border: 2px solid var(--color-border-subtle);
    border-radius: var(--radius-xl);
    padding: var(--space-3);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-group:focus-within {
    border-color: var(--color-brand-500);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

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

.btn-attach:hover {
    background: var(--color-surface-subtle);
    color: var(--color-brand-500);
}

.input-field {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    font-family: var(--font-family-interface);
    font-size: 0.875rem;
    color: var(--color-text-primary);
    line-height: 1.5;
    max-height: 120px;
    min-height: 36px;
}

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

.btn-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gradient-brand);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-card);
}

.btn-send:hover:not(:disabled) {
    transform: scale(1.1) translateY(-2px);
    box-shadow: var(--shadow-thick);
}

.btn-send:disabled {
    background: var(--color-surface-tertiary);
    color: var(--color-text-tertiary);
    cursor: not-allowed;
    box-shadow: none;
}

/* =========================================
   Quick Actions - Playful chips
   ========================================= */

.quick-actions {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-3);
    flex-wrap: wrap;
}

.chip {
    font-family: var(--font-family-interface);
    font-size: 0.75rem;
    font-weight: var(--font-weight-medium);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-full);
    background: var(--color-surface-card);
    border: 1px solid var(--color-border-subtle);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.chip:hover {
    background: var(--gradient-subtle);
    border-color: var(--color-brand-300);
    color: var(--color-brand-700);
    transform: translateY(-2px);
    box-shadow: var(--shadow-thin);
}

/* =========================================
   Attachment Preview System
   ========================================= */

.attachments-row {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
    flex-wrap: wrap;
}

.attachment-thumb {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 2px solid var(--color-border-subtle);
    box-shadow: var(--shadow-thin);
}

.attachment-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.attachment-remove {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-error);
    color: white;
    border: 2px solid white;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-thin);
    transition: all 0.2s;
}

.attachment-remove:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-card);
}

/* =========================================
   Loading States - Consistent animations
   ========================================= */

.loading-indicator {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--color-text-secondary);
    font-family: var(--font-family-interface);
    font-size: 0.875rem;
}

.spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--color-surface-tertiary);
    border-top-color: var(--color-brand-500);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

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

/* =========================================
   Responsive Design - Mobile first
   ========================================= */

@media (max-width: 768px) {
    .workspace-container {
        flex-direction: column;
    }

    .workspace-sidebar {
        width: 100%;
        max-height: 200px;
        padding: var(--space-3);
        overflow-x: auto;
    }

    .nav-list {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: var(--space-2);
    }

    .btn-nav {
        min-width: 100px;
        flex-direction: column;
        gap: var(--space-1);
        text-align: center;
        padding: var(--space-2);
    }

    .workspace-main {
        padding: var(--space-3);
    }

    .chat-messages {
        padding: var(--space-4);
    }

    .message-bubble {
        max-width: 85%;
    }
}

/* =========================================
   Utility Classes - DRY principle
   ========================================= */

.text-display {
    font-family: var(--font-family-display);
    font-size: 2rem;
    font-weight: var(--font-weight-bold);
    line-height: 1.2;
}

.text-h1 {
    font-family: var(--font-family-display);
    font-size: 1.5rem;
    font-weight: var(--font-weight-semibold);
    line-height: 1.3;
}

.text-h2 {
    font-family: var(--font-family-accent);
    font-size: 1.25rem;
    font-weight: var(--font-weight-semibold);
    line-height: 1.4;
}

.text-body {
    font-family: var(--font-family-interface);
    font-size: 1rem;
    font-weight: var(--font-weight-regular);
    line-height: 1.6;
}

.text-small {
    font-family: var(--font-family-interface);
    font-size: 0.875rem;
    font-weight: var(--font-weight-regular);
    line-height: 1.5;
}

.text-tiny {
    font-family: var(--font-family-interface);
    font-size: 0.75rem;
    font-weight: var(--font-weight-regular);
    line-height: 1.4;
}

/* Spacing utilities */
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }

.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }

.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }