/**
 * Codequiry Contact Widget
 * Vercel-inspired minimal design
 * @version 5.0.0
 */

/* ========================================
   CSS Variables - Vercel Design System
   ======================================== */
:root {
    /* Vercel-style colors - Light Mode */
    --cw-bg: #ffffff;
    --cw-bg-secondary: #fafafa;
    --cw-bg-tertiary: #f5f5f5;
    --cw-bg-hover: #f0f0f0;
    --cw-border: #eaeaea;
    --cw-border-hover: #999;
    --cw-text: #000000;
    --cw-text-secondary: #666666;
    --cw-text-tertiary: #888888;
    --cw-accent: #000000;
    --cw-accent-hover: #333333;
    --cw-success: #0070f3;
    --cw-error: #ee0000;
    --cw-shadow: 0 4px 14px 0 rgba(0, 0, 0, 0.1);
    --cw-shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
    --cw-radius: 8px;
    --cw-radius-lg: 12px;
    --cw-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --cw-font-mono: 'Geist Mono', 'SF Mono', 'Fira Code', monospace;
}

/* Dark Mode - Vercel Dark */
[data-kt-theme-mode="dark"],
[data-theme="dark"],
.dark {
    --cw-bg: #0a0a0a;
    --cw-bg-secondary: #111111;
    --cw-bg-tertiary: #1a1a1a;
    --cw-bg-hover: #222222;
    --cw-border: #333333;
    --cw-border-hover: #555555;
    --cw-text: #ededed;
    --cw-text-secondary: #a1a1a1;
    --cw-text-tertiary: #888888;
    --cw-accent: #ffffff;
    --cw-accent-hover: #cccccc;
    --cw-success: #0070f3;
    --cw-error: #ff4444;
    --cw-shadow: 0 4px 14px 0 rgba(0, 0, 0, 0.4);
    --cw-shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
}

/* ========================================
   Widget Container
   ======================================== */
.cw-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: var(--cw-font);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   Launcher Button - Vercel Style
   ======================================== */
.cw-launcher {
    width: 48px;
    height: 48px;
    border: 1px solid var(--cw-border);
    border-radius: 50%;
    background: var(--cw-bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--cw-shadow);
    transition: all 0.2s ease;
    position: relative;
}

.cw-launcher:hover {
    border-color: var(--cw-border-hover);
    box-shadow: var(--cw-shadow-lg);
    transform: translateY(-1px);
}

.cw-launcher:active {
    transform: scale(0.96);
}

.cw-launcher-icon {
    width: 20px;
    height: 20px;
    color: var(--cw-text);
    transition: all 0.15s ease;
    position: absolute;
}

.cw-launcher-close {
    opacity: 0;
    transform: rotate(-45deg) scale(0.8);
}

.cw-launcher.is-open .cw-launcher-icon:not(.cw-launcher-close) {
    opacity: 0;
    transform: rotate(45deg) scale(0.8);
}

.cw-launcher.is-open .cw-launcher-close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* ========================================
   Messenger Panel - Vercel Style
   ======================================== */
.cw-messenger {
    position: absolute;
    bottom: 60px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 48px);
    max-height: min(600px, calc(100vh - 120px));
    background: var(--cw-bg);
    border: 1px solid var(--cw-border);
    border-radius: var(--cw-radius-lg);
    box-shadow: var(--cw-shadow-lg);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px) scale(0.98);
    transform-origin: bottom right;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

.cw-messenger.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ========================================
   Header - Minimal Vercel Style
   ======================================== */
.cw-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--cw-border);
    background: var(--cw-bg);
}

.cw-header-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}

.cw-header-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #000 0%, #333 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

[data-kt-theme-mode="dark"] .cw-header-avatar,
.dark .cw-header-avatar {
    background: linear-gradient(135deg, #fff 0%, #ccc 100%);
}

.cw-header-avatar svg {
    width: 16px;
    height: 16px;
    color: #fff;
}

[data-kt-theme-mode="dark"] .cw-header-avatar svg,
.dark .cw-header-avatar svg {
    color: #000;
}

.cw-header-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--cw-text);
    margin: 0;
    letter-spacing: -0.02em;
}

.cw-header-subtitle {
    font-size: 13px;
    color: var(--cw-text-tertiary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cw-status-dot {
    width: 6px;
    height: 6px;
    background: #00d26a;
    border-radius: 50%;
    animation: cw-pulse 2s ease-in-out infinite;
}

@keyframes cw-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ========================================
   Body - Content Area
   ======================================== */
.cw-body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.cw-body::-webkit-scrollbar {
    width: 4px;
}

.cw-body::-webkit-scrollbar-track {
    background: transparent;
}

.cw-body::-webkit-scrollbar-thumb {
    background: var(--cw-border);
    border-radius: 2px;
}

/* ========================================
   Home View
   ======================================== */
.cw-home {
    padding: 16px 20px 20px;
}

/* Primary Card - Vercel Style */
.cw-card {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 14px 16px;
    background: var(--cw-bg-secondary);
    border: 1px solid var(--cw-border);
    border-radius: var(--cw-radius);
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
}

.cw-card:hover {
    background: var(--cw-bg-hover);
    border-color: var(--cw-border-hover);
}

.cw-card-icon {
    width: 36px;
    height: 36px;
    background: var(--cw-text);
    border-radius: var(--cw-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cw-card-icon svg {
    width: 18px;
    height: 18px;
    color: var(--cw-bg);
}

.cw-card-content {
    flex: 1;
    min-width: 0;
}

.cw-card-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--cw-text);
    margin: 0 0 2px;
}

.cw-card-desc {
    font-size: 13px;
    color: var(--cw-text-tertiary);
    margin: 0;
}

.cw-card-arrow {
    width: 16px;
    height: 16px;
    color: var(--cw-text-tertiary);
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

.cw-card:hover .cw-card-arrow {
    transform: translateX(2px);
}

/* Quick Links */
.cw-quick-links {
    margin-top: 16px;
    border-top: 1px solid var(--cw-border);
    padding-top: 12px;
}

.cw-quick-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 400;
    color: var(--cw-text-secondary);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.15s ease;
    width: 100%;
    text-align: left;
}

.cw-quick-link:hover {
    color: var(--cw-text);
}

.cw-quick-link svg {
    width: 16px;
    height: 16px;
    opacity: 0.6;
}

.cw-quick-link:hover svg {
    opacity: 1;
}

/* ========================================
   FAQ View - Vercel Accordion
   ======================================== */
.cw-faq {
    padding: 0;
}

.cw-faq-nav {
    padding: 12px 20px;
    border-bottom: 1px solid var(--cw-border);
    background: var(--cw-bg);
    position: sticky;
    top: 0;
    z-index: 1;
}

.cw-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px 6px 8px;
    background: var(--cw-bg-secondary);
    border: 1px solid var(--cw-border);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--cw-text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.cw-back:hover {
    background: var(--cw-bg-hover);
    color: var(--cw-text);
    border-color: var(--cw-border-hover);
}

.cw-back svg {
    width: 14px;
    height: 14px;
}

.cw-faq-header {
    padding: 16px 20px 12px;
}

.cw-faq-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--cw-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
}

.cw-faq-list {
    padding: 0 20px;
}

.cw-faq-item {
    border-bottom: 1px solid var(--cw-border);
}

.cw-faq-item:last-child {
    border-bottom: none;
}

.cw-faq-question {
    width: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 0;
    background: transparent;
    border: none;
    font-size: 14px;
    font-weight: 400;
    color: var(--cw-text);
    text-align: left;
    cursor: pointer;
    transition: color 0.15s ease;
}

.cw-faq-question:hover {
    color: var(--cw-text-secondary);
}

.cw-faq-question span {
    flex: 1;
    line-height: 1.5;
}

.cw-faq-icon {
    width: 16px;
    height: 16px;
    color: var(--cw-text-tertiary);
    transition: transform 0.2s ease;
    flex-shrink: 0;
    margin-top: 2px;
}

.cw-faq-question.is-open .cw-faq-icon {
    transform: rotate(180deg);
}

.cw-faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.cw-faq-answer.is-open {
    max-height: 300px;
    padding-bottom: 14px;
}

.cw-faq-answer p {
    font-size: 13px;
    line-height: 1.6;
    color: var(--cw-text-secondary);
    margin: 0;
    padding-right: 28px;
}

.cw-faq-footer {
    padding: 16px 20px 20px;
    border-top: 1px solid var(--cw-border);
    margin-top: 8px;
}

.cw-faq-footer p {
    font-size: 13px;
    color: var(--cw-text-tertiary);
    margin: 0 0 12px;
    text-align: center;
}

.cw-faq-contact {
    width: 100%;
    padding: 10px 16px;
    background: var(--cw-text);
    color: var(--cw-bg);
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: var(--cw-radius);
    cursor: pointer;
    transition: all 0.15s ease;
}

.cw-faq-contact:hover {
    opacity: 0.85;
}

/* ========================================
   Compose View
   ======================================== */
.cw-compose {
    padding: 0;
}

.cw-nav {
    padding: 12px 20px;
    border-bottom: 1px solid var(--cw-border);
    background: var(--cw-bg);
    position: sticky;
    top: 0;
    z-index: 1;
}

.cw-form-container {
    padding: 16px 20px 20px;
}

/* Form Fields */
.cw-field {
    margin-bottom: 16px;
}

.cw-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--cw-text);
    margin-bottom: 6px;
}

.cw-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--cw-bg);
    border: 1px solid var(--cw-border);
    border-radius: var(--cw-radius);
    font-family: inherit;
    font-size: 14px;
    color: var(--cw-text);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cw-input:focus {
    border-color: var(--cw-text);
    box-shadow: 0 0 0 1px var(--cw-text);
}

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

.cw-textarea {
    min-height: 100px;
    resize: none;
    line-height: 1.5;
}

/* Topics */
.cw-topics {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cw-topic {
    padding: 6px 12px;
    background: var(--cw-bg);
    border: 1px solid var(--cw-border);
    border-radius: 100px;
    font-size: 13px;
    font-weight: 400;
    color: var(--cw-text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.cw-topic input {
    display: none;
}

.cw-topic:hover {
    border-color: var(--cw-border-hover);
    color: var(--cw-text);
}

.cw-topic.is-active {
    background: var(--cw-text);
    border-color: var(--cw-text);
    color: var(--cw-bg);
}

/* Submit Button */
.cw-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    margin-top: 20px;
    background: var(--cw-text);
    border: none;
    border-radius: var(--cw-radius);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--cw-bg);
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.cw-submit:hover:not(:disabled) {
    opacity: 0.85;
}

.cw-submit:active:not(:disabled) {
    transform: scale(0.98);
}

.cw-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cw-submit svg {
    width: 16px;
    height: 16px;
}

/* ========================================
   Success View
   ======================================== */
.cw-success {
    padding: 48px 24px;
    text-align: center;
}

.cw-success-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    background: var(--cw-bg-secondary);
    border: 1px solid var(--cw-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cw-success-icon svg {
    width: 24px;
    height: 24px;
    color: var(--cw-success);
}

.cw-success-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--cw-text);
    margin: 0 0 8px;
    letter-spacing: -0.02em;
}

.cw-success-desc {
    font-size: 14px;
    color: var(--cw-text-tertiary);
    margin: 0;
    line-height: 1.5;
}

/* ========================================
   Spinner
   ======================================== */
.cw-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: cw-spin 0.6s linear infinite;
}

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

/* ========================================
   Toast Notifications
   ======================================== */
.cw-toast {
    position: fixed;
    bottom: 84px;
    right: 24px;
    padding: 12px 16px;
    background: var(--cw-bg);
    border: 1px solid var(--cw-border);
    border-radius: var(--cw-radius);
    box-shadow: var(--cw-shadow-lg);
    font-size: 14px;
    font-weight: 400;
    color: var(--cw-text);
    z-index: 100000;
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    transform: translateY(8px);
    transition: all 0.2s ease;
}

.cw-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.cw-toast.is-error {
    border-color: var(--cw-error);
}

.cw-toast.is-error svg {
    color: var(--cw-error);
}

.cw-toast.is-success svg {
    color: var(--cw-success);
}

.cw-toast svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ========================================
   Mobile Responsive
   ======================================== */
@media (max-width: 480px) {
    .cw-widget {
        bottom: 16px;
        right: 16px;
    }
    
    .cw-launcher {
        width: 44px;
        height: 44px;
    }
    
    .cw-launcher-icon {
        width: 18px;
        height: 18px;
    }
    
    .cw-messenger {
        bottom: 56px;
        width: calc(100vw - 32px);
        max-height: calc(100vh - 88px);
    }
    
    .cw-toast {
        right: 16px;
        left: 16px;
        bottom: 72px;
    }
}
