/**
 * Codequiry Contact Widget
 * Clean, minimal Vercel × Apple inspired design
 * @version 7.0.0
 */

/* ========================================
   CSS Variables - Professional Design System
   ======================================== */
:root {
    /* Clean Light Mode - Vercel/Apple inspired */
    --cw-bg: #ffffff;
    --cw-bg-elevated: #ffffff;
    --cw-bg-secondary: #fafafa;
    --cw-bg-tertiary: #f5f5f5;
    --cw-bg-hover: #f0f0f0;
    --cw-border: #eaeaea;
    --cw-border-hover: #d4d4d4;
    --cw-border-focus: #0070f3;
    --cw-text: #171717;
    --cw-text-secondary: #525252;
    --cw-text-tertiary: #737373;
    --cw-text-muted: #a3a3a3;
    --cw-accent: #0070f3;
    --cw-accent-hover: #0060df;
    --cw-accent-light: rgba(0, 112, 243, 0.08);
    --cw-success: #10b981;
    --cw-success-light: rgba(16, 185, 129, 0.08);
    --cw-error: #ef4444;
    --cw-error-light: rgba(239, 68, 68, 0.08);
    --cw-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --cw-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    --cw-shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
    --cw-shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.16);
    --cw-radius-sm: 6px;
    --cw-radius: 8px;
    --cw-radius-lg: 12px;
    --cw-radius-xl: 16px;
    --cw-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
    --cw-transition: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Clean Dark Mode */
[data-kt-theme-mode="dark"],
[data-theme="dark"],
.dark {
    --cw-bg: #0a0a0a;
    --cw-bg-elevated: #141414;
    --cw-bg-secondary: #171717;
    --cw-bg-tertiary: #1f1f1f;
    --cw-bg-hover: #262626;
    --cw-border: #262626;
    --cw-border-hover: #404040;
    --cw-border-focus: #0070f3;
    --cw-text: #fafafa;
    --cw-text-secondary: #a1a1aa;
    --cw-text-tertiary: #71717a;
    --cw-text-muted: #52525b;
    --cw-accent: #3b82f6;
    --cw-accent-hover: #60a5fa;
    --cw-accent-light: rgba(59, 130, 246, 0.12);
    --cw-success: #22c55e;
    --cw-success-light: rgba(34, 197, 94, 0.12);
    --cw-error: #f87171;
    --cw-error-light: rgba(248, 113, 113, 0.12);
    --cw-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --cw-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    --cw-shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --cw-shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.6);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-kt-theme-mode="light"]) {
        --cw-bg: #0a0a0a;
        --cw-bg-elevated: #141414;
        --cw-bg-secondary: #171717;
        --cw-bg-tertiary: #1f1f1f;
        --cw-bg-hover: #262626;
        --cw-border: #262626;
        --cw-border-hover: #404040;
        --cw-border-focus: #0070f3;
        --cw-text: #fafafa;
        --cw-text-secondary: #a1a1aa;
        --cw-text-tertiary: #71717a;
        --cw-text-muted: #52525b;
        --cw-accent: #3b82f6;
        --cw-accent-hover: #60a5fa;
        --cw-accent-light: rgba(59, 130, 246, 0.12);
        --cw-success: #22c55e;
        --cw-success-light: rgba(34, 197, 94, 0.12);
        --cw-error: #f87171;
        --cw-error-light: rgba(248, 113, 113, 0.12);
        --cw-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
        --cw-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
        --cw-shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
        --cw-shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.6);
    }
}

/* ========================================
   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 - Clean Floating Action
   ======================================== */
.cw-launcher {
    width: 52px;
    height: 52px;
    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-lg);
    transition: all 0.2s var(--cw-transition);
    position: relative;
}

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

.cw-launcher:active {
    transform: translateY(0);
    transition-duration: 0.1s;
}

.cw-launcher-icon {
    width: 22px;
    height: 22px;
    color: var(--cw-text);
    transition: all 0.2s var(--cw-transition);
    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 - Clean Card
   ======================================== */
.cw-messenger {
    position: absolute;
    bottom: 64px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 32px);
    max-height: min(560px, calc(100vh - 120px));
    background: var(--cw-bg);
    border: 1px solid var(--cw-border);
    border-radius: var(--cw-radius-xl);
    box-shadow: var(--cw-shadow-xl);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px) scale(0.98);
    transform-origin: bottom right;
    transition: all 0.2s var(--cw-transition);
    overflow: hidden;
}

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

/* ========================================
   Header - Clean Minimal
   ======================================== */
.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: 36px;
    height: 36px;
    background: var(--cw-accent);
    border-radius: var(--cw-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cw-header-avatar svg {
    width: 18px;
    height: 18px;
    color: white;
}

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

.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: var(--cw-success);
    border-radius: 50%;
}

/* ========================================
   Body - Content Container
   ======================================== */
.cw-body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--cw-bg-secondary);
}

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

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

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

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

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

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

.cw-card:active {
    transform: scale(0.99);
}

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

.cw-card-icon svg {
    width: 16px;
    height: 16px;
    color: white;
}

.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: 12px;
    color: var(--cw-text-tertiary);
    margin: 0;
}

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

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

/* Quick Links */
.cw-quick-links {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

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

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

.cw-quick-link svg {
    width: 16px;
    height: 16px;
    color: var(--cw-text-tertiary);
    transition: color 0.15s var(--cw-transition);
}

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

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

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

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

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

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

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

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

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

.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: 12px 0;
    background: transparent;
    border: none;
    font-size: 13px;
    font-weight: 500;
    color: var(--cw-text);
    text-align: left;
    cursor: pointer;
    transition: color 0.15s var(--cw-transition);
}

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

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

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

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

.cw-faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: all 0.25s var(--cw-transition);
}

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

.cw-faq-answer p {
    font-size: 13px;
    line-height: 1.6;
    color: var(--cw-text-secondary);
    margin: 0;
    padding: 10px 12px;
    background: var(--cw-bg);
    border-radius: var(--cw-radius);
    border-left: 2px solid var(--cw-accent);
}

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

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

.cw-faq-contact {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 10px 16px;
    background: var(--cw-accent);
    color: white;
    font-size: 13px;
    font-weight: 500;
    border: none;
    border-radius: var(--cw-radius);
    cursor: pointer;
    transition: all 0.15s var(--cw-transition);
}

.cw-faq-contact:hover {
    background: var(--cw-accent-hover);
}

.cw-faq-contact:active {
    transform: scale(0.98);
}

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

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

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

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

.cw-label {
    display: block;
    font-size: 12px;
    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: 13px;
    color: var(--cw-text);
    outline: none;
    transition: all 0.15s var(--cw-transition);
}

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

.cw-input:focus {
    border-color: var(--cw-accent);
    box-shadow: 0 0 0 3px var(--cw-accent-light);
}

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

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

/* Topic Pills */
.cw-topics {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

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

.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-accent);
    border-color: var(--cw-accent);
    color: white;
}

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

.cw-submit:hover:not(:disabled) {
    background: var(--cw-accent-hover);
}

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

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

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

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

.cw-success-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    background: var(--cw-success-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: cw-pop 0.3s var(--cw-transition);
}

@keyframes cw-pop {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.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;
}

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

/* ========================================
   Spinner
   ======================================== */
.cw-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: cw-spin 0.6s linear infinite;
}

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

/* ========================================
   Toast Notifications
   ======================================== */
.cw-toast {
    position: fixed;
    bottom: 88px;
    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: 13px;
    font-weight: 500;
    color: var(--cw-text);
    z-index: 100000;
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    transform: translateY(8px);
    transition: all 0.2s var(--cw-transition);
}

.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 {
    border-color: var(--cw-success);
}

.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: 48px;
        height: 48px;
    }
    
    .cw-launcher-icon {
        width: 20px;
        height: 20px;
    }
    
    .cw-messenger {
        bottom: 60px;
        width: calc(100vw - 32px);
        max-height: calc(100vh - 100px);
    }
    
    .cw-toast {
        right: 16px;
        left: 16px;
        bottom: 76px;
    }
}

/* ========================================
   Reduced Motion
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    .cw-launcher,
    .cw-launcher-icon,
    .cw-messenger,
    .cw-card,
    .cw-quick-link,
    .cw-faq-icon,
    .cw-faq-answer,
    .cw-topic,
    .cw-submit,
    .cw-toast,
    .cw-success-icon {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
}
