@import url('/design-system/platform-tokens.css');

/* ==========================================================================
   AI Builder Drawer - Right-sliding drawer for AI Workshop Builder
   ========================================================================== */

/* Drawer Container */
.ai-builder-drawer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
    visibility: hidden;
    pointer-events: none;
}

.ai-builder-drawer.open {
    visibility: visible;
    pointer-events: auto;
}

/* Overlay */
.ai-builder-drawer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ai-builder-drawer.open .ai-builder-drawer-overlay {
    opacity: 1;
}

/* Drawer Content Panel */
.ai-builder-drawer-content {
    position: absolute;
    top: 0;
    right: -600px;
    width: 600px;
    max-width: 100%;
    height: 100%;
    background: var(--bg-page-alt);
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.15);
    border-left: 2px solid var(--mainsite-primary);
}

.ai-builder-drawer-content::before {
    content: '';
    position: absolute;
    left: -2px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 100px;
    background: var(--mainsite-primary);
    border-radius: 0 3px 3px 0;
    z-index: 1;
}

.ai-builder-drawer.open .ai-builder-drawer-content {
    right: 0;
}

/* Header (Modal Style) */
.ai-builder-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--mainsite-primary);
    flex-shrink: 0;
}

.ai-builder-drawer-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-builder-drawer-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.ai-builder-drawer-header-info {
    display: flex;
    flex-direction: column;
}

.ai-builder-drawer-header-title {
    font-family: var(--font-body);
    font-size: 16px;
    font-weight: 600;
    color: white;
    margin: 0;
    line-height: 1.3;
}

.ai-builder-drawer-header-status {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

.ai-builder-drawer-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-builder-drawer-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--gray-100);
    border: none;
    border-radius: var(--radius-lg);
    color: var(--gray-500);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.ai-builder-drawer-btn:hover {
    background: var(--gray-200);
    color: var(--gray-900);
}

.ai-builder-drawer-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: var(--radius-lg);
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-builder-drawer-close svg {
    transition: transform 0.2s ease;
}

.ai-builder-drawer-close:hover {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

.ai-builder-drawer-close:hover svg {
    transform: rotate(90deg);
}

/* Chat Container */
.ai-builder-drawer-chat {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px;
}

/* Welcome Screen */
.ai-builder-drawer-welcome {
    text-align: left;
    padding: 40px 20px;
}

.ai-builder-drawer-welcome.hidden {
    display: none;
}

.drawer-welcome-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    background: var(--mainsite-light);
    border-radius: 50%;
    margin: 0 auto 20px;
    color: var(--mainsite-primary);
}

.ai-builder-drawer-welcome h3 {
    font-family: var(--font-body);
    font-size: 20px;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0 0 8px;
    text-align: center;
}

.ai-builder-drawer-welcome p {
    font-size: 14px;
    color: var(--gray-500);
    margin: 0 0 24px;
    line-height: 1.5;
}

.drawer-welcome-suggestions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.drawer-welcome-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-900);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.drawer-welcome-btn:hover {
    background: var(--gray-100);
    border-color: var(--gray-300);
}

.drawer-welcome-btn.primary {
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    color: var(--gray-900);
}

.drawer-welcome-btn.primary:hover {
    background: var(--mainsite-light);
    border-color: var(--mainsite-primary);
    color: var(--gray-900);
}

.drawer-welcome-btn.primary:active,
.drawer-welcome-btn.primary.active {
    background: var(--mainsite-primary);
    border-color: var(--mainsite-primary);
    color: white;
}

.drawer-welcome-btn svg {
    flex-shrink: 0;
}

/* Messages Container */
.ai-builder-drawer-messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Message Styles */
.drawer-message {
    display: flex;
    gap: 12px;
}

.drawer-message.user {
    flex-direction: row-reverse;
}

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

.drawer-message.assistant .drawer-message-avatar {
    background: linear-gradient(135deg, var(--mainsite-primary) 0%, var(--mainsite-dark) 100%);
    color: white;
}

.drawer-message.user .drawer-message-avatar {
    background: var(--mainsite-primary);
    color: white;
}

.drawer-message-content {
    flex: 1;
    min-width: 0;
}

.drawer-message-bubble {
    padding: 12px 16px;
    border-radius: var(--radius-xl);
    font-size: 14px;
    line-height: 1.6;
}

.drawer-message.assistant .drawer-message-bubble {
    background: var(--bg-surface);
    border: 1px solid var(--gray-200);
    color: var(--gray-900);
    border-top-left-radius: var(--radius-sm);
}

.drawer-message.user .drawer-message-bubble {
    background: var(--mainsite-light);
    color: var(--gray-900);
    border-top-right-radius: var(--radius-sm);
}

.drawer-message-bubble p {
    margin: 0 0 8px;
}

.drawer-message-bubble p:last-child {
    margin-bottom: 0;
}

/* Cards Grid */
.drawer-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.drawer-content-card {
    background: var(--bg-surface);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 14px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.drawer-content-card:hover {
    border-color: var(--mainsite-primary);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--color-info) 10%, transparent);
}

.drawer-content-card-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.drawer-content-card.exercise .drawer-content-card-icon {
    background: var(--color-info-very-light);
    color: var(--coach-primary);
}

.drawer-content-card.icebreaker .drawer-content-card-icon {
    background: var(--color-warning-very-light);
    color: var(--color-warning-dark);
}

.drawer-content-card-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0 0 6px;
    line-height: 1.3;
}

.drawer-content-card-meta {
    display: flex;
    gap: 8px;
    font-size: 11px;
    color: var(--gray-500);
}

.drawer-content-card-overview {
    font-size: 12px;
    color: var(--gray-500);
    margin: 8px 0 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.drawer-content-card-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

.drawer-card-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 10px;
    background: var(--gray-100);
    border: none;
    border-radius: var(--radius-md);
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    transition: all 0.2s ease;
}

.drawer-card-btn:hover {
    background: var(--gray-200);
    color: var(--gray-900);
}

/* Tips Cards */
.drawer-tips {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 12px;
}

.drawer-tip-card {
    background: var(--bg-surface);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 14px;
    text-decoration: none;
    transition: all 0.2s ease;
    display: block;
}

.drawer-tip-card:hover {
    border-color: var(--mainsite-primary);
    background: var(--gray-50);
}

.drawer-tip-card-category {
    display: inline-block;
    padding: 3px 8px;
    background: var(--color-warning-very-light);
    color: var(--color-warning-dark);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.drawer-tip-card-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0 0 6px;
}

.drawer-tip-card-overview {
    font-size: 12px;
    color: var(--gray-500);
    margin: 0;
    line-height: 1.5;
}

/* Typing Indicator */
.drawer-typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-xl);
    border-top-left-radius: var(--radius-sm);
}

.drawer-typing-dots {
    display: flex;
    gap: 4px;
}

.drawer-typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--gray-400);
    border-radius: 50%;
    animation: drawerTypingBounce 1.4s infinite ease-in-out both;
}

.drawer-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.drawer-typing-dots span:nth-child(2) { animation-delay: -0.16s; }
.drawer-typing-dots span:nth-child(3) { animation-delay: 0; }

@keyframes drawerTypingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Skeleton Loading */
.drawer-skeleton-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.drawer-skeleton-card {
    background: var(--bg-surface);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 14px;
}

.drawer-skeleton-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: drawerSkeletonShimmer 1.5s infinite;
    border-radius: var(--radius-lg);
    margin-bottom: 10px;
}

.drawer-skeleton-title {
    height: 14px;
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: drawerSkeletonShimmer 1.5s infinite;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    width: 80%;
}

.drawer-skeleton-meta {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.drawer-skeleton-badge {
    height: 10px;
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: drawerSkeletonShimmer 1.5s infinite;
    border-radius: 3px;
    width: 40px;
}

.drawer-skeleton-text {
    height: 10px;
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: drawerSkeletonShimmer 1.5s infinite;
    border-radius: 3px;
    margin-bottom: 6px;
}

.drawer-skeleton-text:last-child {
    width: 60%;
}

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

/* Input Area */
.ai-builder-drawer-input-area {
    padding: 12px 20px 16px;
    background: var(--bg-surface);
    border-top: 1px solid var(--gray-200);
    flex-shrink: 0;
}

.ai-builder-drawer-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.ai-builder-drawer-suggestions:empty {
    display: none;
}

.drawer-suggestion-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    transition: all 0.2s ease;
}

.drawer-suggestion-chip:hover {
    background: var(--gray-200);
    border-color: var(--gray-300);
    color: var(--gray-900);
}

.ai-builder-drawer-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-xl);
    padding: 8px 12px;
    transition: border-color 0.2s ease;
}

.ai-builder-drawer-input-wrapper:focus-within {
    border-color: var(--mainsite-primary);
}

.ai-builder-drawer-input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    color: var(--gray-900);
    resize: none;
    min-height: 24px;
    max-height: 120px;
    outline: none;
}

.ai-builder-drawer-input::placeholder {
    color: var(--gray-400);
}

.ai-builder-drawer-send {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    background: var(--mainsite-primary);
    border: none;
    border-radius: var(--radius-lg);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.ai-builder-drawer-send:hover {
    background: var(--mainsite-dark);
}

.ai-builder-drawer-send:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
}

.ai-builder-drawer-disclaimer {
    font-size: 11px;
    color: var(--gray-400);
    text-align: center;
    margin: 8px 0 0;
}

/* Workshop Form Modal (nested inside drawer) */
.drawer-workshop-form-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 10;
}

.drawer-workshop-form-container {
    background: var(--bg-surface);
    border-radius: var(--radius-2xl);
    width: 100%;
    max-width: 480px;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-xl);
}

.drawer-workshop-form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--mainsite-primary);
    flex-shrink: 0;
}

.drawer-workshop-form-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: white;
    margin: 0;
}

.drawer-workshop-form-close {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.drawer-workshop-form-close svg {
    transition: transform 0.2s ease;
}

.drawer-workshop-form-close:hover {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

.drawer-workshop-form-close:hover svg {
    transform: rotate(90deg);
}

.drawer-workshop-form-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.drawer-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.drawer-form-group {
    margin-bottom: 16px;
}

.drawer-form-group:last-child {
    margin-bottom: 0;
}

.drawer-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.drawer-form-group select,
.drawer-form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    font-family: inherit;
    font-size: 14px;
    color: var(--gray-900);
    background: var(--bg-surface);
    transition: border-color 0.2s ease;
}

.drawer-form-group select:focus,
.drawer-form-group textarea:focus {
    outline: none;
    border-color: var(--mainsite-primary);
}

.drawer-form-group textarea {
    resize: none;
}

/* Templates Grid */
.drawer-templates {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.drawer-template {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    background: var(--gray-100);
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
}

.drawer-template:hover {
    background: var(--gray-200);
}

.drawer-template.selected {
    background: var(--mainsite-light);
    border-color: var(--mainsite-primary);
}

.drawer-template svg {
    color: var(--gray-500);
}

.drawer-template.selected svg {
    color: var(--mainsite-primary);
}

.drawer-template span {
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-700);
    text-align: center;
}

.drawer-workshop-form-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--gray-200);
}

.drawer-form-cancel {
    padding: 10px 16px;
    background: transparent;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    transition: all 0.2s ease;
}

.drawer-form-cancel:hover {
    background: var(--gray-100);
    border-color: var(--gray-300);
}

.drawer-form-submit {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--mainsite-primary);
    border: none;
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 500;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.drawer-form-submit:hover {
    background: var(--mainsite-dark);
}

/* Mobile Responsive */
@media (max-width: 640px) {
    .ai-builder-drawer-content {
        width: 100%;
        right: -100%;
    }

    .drawer-cards {
        grid-template-columns: 1fr;
    }

    .drawer-tips {
        grid-template-columns: 1fr;
    }

    .drawer-templates {
        grid-template-columns: repeat(2, 1fr);
    }

    .drawer-form-row {
        grid-template-columns: 1fr;
    }
}

/* Body scroll lock when drawer is open */
body.ai-builder-drawer-open {
    overflow: hidden;
}
