/* Chat Builder - Claymorphism components (chastnbot reference-aligned) */

.clay-card {
    background: var(--color-surface);
    border-radius: var(--radius-base);
    box-shadow: var(--shadow-clay-card);
}

.clay-pressed {
    box-shadow: var(--shadow-clay-pressed);
}

.clay-btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-pill);
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-card);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    font-size: 14px;
    color: var(--color-text-primary);
    text-decoration: none;
}
.clay-btn:hover,
.clay-btn:focus,
.clay-btn:active {
    text-decoration: none;
}

.clay-btn:hover {
    transform: scale(1.02);
}

.clay-btn:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-clay-pressed);
}

.clay-btn-primary,
.btn-primary {
    background: var(--color-primary);
    color: var(--color-primary-foreground);
    box-shadow: var(--shadow-clay-btn-primary);
    border-radius: var(--radius-pill);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.clay-btn-primary:hover,
.btn-primary:hover {
    transform: scale(1.02);
}

.clay-btn-primary:active,
.btn-primary:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-clay-pressed);
}

.clay-btn-secondary {
    background: var(--color-surface);
    color: var(--color-text-primary);
    box-shadow: var(--shadow-clay-card);
}

.clay-btn-secondary:hover {
    transform: scale(1.02);
}

.clay-btn-ghost {
    background: transparent;
    box-shadow: none;
}

.clay-btn-ghost:hover {
    background: var(--color-muted);
}

.clay-btn-danger {
    background: var(--color-danger);
    color: #fff;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
}

.clay-btn-danger:hover {
    transform: scale(1.02);
}

.clay-btn-circle {
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 50%;
    border: none;
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-card);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.clay-btn-circle:hover {
    transform: scale(1.02);
}

.clay-btn-circle:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-clay-pressed);
}

.clay-input {
    padding: 14px 18px;
    border: none;
    border-radius: var(--radius-input);
    background: var(--color-input-bg);
    box-shadow: var(--shadow-clay-input);
    font-size: 16px;
    color: var(--color-text-primary);
}

.clay-input::placeholder {
    color: var(--color-text-secondary);
}

.clay-input:focus {
    outline: none;
}

textarea.clay-input {
    border-radius: var(--radius-input);
    resize: vertical;
    min-height: 80px;
}

.clay-select {
    padding: 14px 18px;
    border: none;
    border-radius: var(--radius-input);
    background: var(--color-input-bg);
    box-shadow: var(--shadow-clay-input);
    font-size: 16px;
    color: var(--color-text-primary);
    cursor: pointer;
    min-height: 48px;
}

.clay-select:focus {
    outline: none;
    box-shadow: var(--shadow-clay-input), var(--shadow-focus);
}

.clay-modal-body {
    margin-top: 0;
    padding-top: 0;
}

.clay-empty-icon {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-card);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.clay-empty-icon svg {
    width: 48px;
    height: 48px;
    color: var(--color-text-secondary);
}

.clay-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    min-width: 180px;
    background: var(--color-surface);
    border-radius: var(--radius-base);
    box-shadow: var(--shadow-clay-card);
    padding: 8px;
    z-index: 1000;
}

.clay-dropdown a,
.clay-dropdown button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 14px;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--color-text-primary);
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.clay-dropdown a:hover,
.clay-dropdown button:hover {
    background: var(--color-muted);
}

/* Hidden checkbox controls modal visibility so close works without JS */
.new-chat-modal-toggle {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.clay-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: none !important;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: clamp(1rem, 4vw, 24px);
    box-sizing: border-box;
    overflow-y: auto;
}

#newChatModalToggle:checked~#newChatModal.clay-modal-overlay {
    display: flex !important;
}

#userProfileModalToggle:checked~#userProfileModal.clay-modal-overlay {
    display: flex !important;
}

.clay-modal {
    background: var(--color-surface);
    border-radius: var(--radius-base);
    box-shadow: var(--shadow-clay-card);
    padding: clamp(1rem, 4vw, 28px);
    max-width: min(440px, calc(100vw - 2rem));
    width: 100%;
    margin: auto;
}

.clay-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.clay-modal-header h3 {
    margin: 0;
    font-size: 20px;
    color: var(--color-text-primary);
}

.clay-modal-close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-pressed);
    cursor: pointer;
    font-size: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    margin: 0;
    /* So label works like a button when used for close */
    -webkit-appearance: none;
    appearance: none;
}

.clay-modal-close:hover {
    color: var(--color-text-primary);
}

/* Let clicks pass through the icon to the button so close always fires */
.clay-modal-close svg {
    pointer-events: none;
}

/* Message bubbles (reference-aligned) */
.message-bubble {
    max-width: 75%;
    padding: 12px 16px;
    margin: 6px 0;
}

/* Sent: same as Send button (primary) */
.message-bubble--sent {
    background: var(--gradient-primary, var(--color-primary));
    color: var(--color-primary-foreground);
    border-radius: var(--radius-bubble) var(--radius-bubble) 0.25rem var(--radius-bubble);
    margin-left: auto;
    box-shadow: none;
    border: 1.5px solid hsl(250, 35%, 45%);
}

.message-bubble--received {
    background: var(--color-message-received);
    color: var(--color-text-primary);
    border-radius: var(--radius-bubble) var(--radius-bubble) var(--radius-bubble) 0.25rem;
    box-shadow: var(--shadow-clay-panel);
    border: 1px solid var(--color-border);
}

[data-theme="dark"] .message-bubble--received {
    box-shadow:
        3px 3px 8px 0px rgba(0, 0, 0, 0.25),
        -1px -1px 4px 0px rgba(255, 255, 255, 0.02);
}

[data-theme="dark"] .message-bubble--sent {
    box-shadow: none;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.msg-content {
    display: block;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.msg-time {
    font-size: 11px;
    opacity: 0.8;
    display: block;
    margin-top: 4px;
}

/* ============================================
   ENHANCED CLAYMORPHISM COMPONENTS
   ============================================ */

/* Clay Avatar */
.clay-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--gradient-surface);
    box-shadow: var(--shadow-avatar);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.clay-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.clay-avatar--sm {
    width: 36px;
    height: 36px;
}

.clay-avatar--lg {
    width: 64px;
    height: 64px;
}

.clay-avatar--xl {
    width: 96px;
    height: 96px;
}

.clay-avatar-status {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--color-surface);
    background: var(--color-offline);
}

.clay-avatar-status--online {
    background: var(--color-online);
}

.clay-avatar-status--away {
    background: var(--color-warning);
}

/* Clay Chip/Tag */
.clay-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-pill);
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-card);
    font-size: 13px;
    color: var(--color-text-primary);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.clay-chip:hover {
    transform: scale(1.02);
}

.clay-chip--active {
    background: var(--gradient-primary);
    color: var(--color-primary-foreground);
}

.clay-chip-remove {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

/* Clay Tabs */
.clay-tabs {
    display: flex;
    gap: 8px;
    padding: 6px;
    background: var(--color-surface);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-clay-input);
}

.clay-tab {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--color-text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clay-tab:hover {
    color: var(--color-text-primary);
}

.clay-tab--active {
    background: var(--color-surface);
    color: var(--color-primary);
    box-shadow: var(--shadow-clay-card);
}

/* Clay Toggle Switch */
.clay-toggle {
    width: 52px;
    height: 28px;
    border-radius: var(--radius-pill);
    background: var(--color-muted);
    box-shadow: var(--shadow-clay-input);
    position: relative;
    cursor: pointer;
    transition: background 0.3s ease;
}

.clay-toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-card);
    transition: transform 0.3s ease;
}

.clay-toggle--on {
    background: var(--color-primary);
}

.clay-toggle--on::after {
    transform: translateX(24px);
}

/* Clay Progress Ring */
.clay-progress-ring {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-card);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.clay-progress-ring svg {
    transform: rotate(-90deg);
}

.clay-progress-ring circle {
    fill: none;
    stroke-width: 6;
}

.clay-progress-ring .track {
    stroke: var(--color-muted);
}

.clay-progress-ring .progress {
    stroke: var(--color-primary);
    stroke-linecap: round;
    transition: stroke-dashoffset 0.3s ease;
}

/* Toast container - top-right, max 3 stacked */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
    pointer-events: none;
}

.toast-container .toast-item {
    pointer-events: auto;
}

.toast-item .toast-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.toast-item .toast-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--color-text-primary);
}

.toast-item .toast-message {
    font-size: 13px;
    color: var(--color-text-secondary);
}

.toast-item.toast-out {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Clay Toast Notification */
.clay-toast {
    padding: 16px 24px;
    background: var(--color-surface);
    border-radius: var(--radius-base);
    box-shadow: var(--shadow-clay-card);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: slideInRight 0.3s ease;
    flex-wrap: wrap;
}

.clay-toast--success {
    border-left: 4px solid var(--color-success);
}

.clay-toast--error {
    border-left: 4px solid var(--color-error);
}

.clay-toast--warning {
    border-left: 4px solid var(--color-warning);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Clay Status Badge */
.clay-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 8px;
    border-radius: var(--radius-pill);
    background: var(--color-primary);
    color: var(--color-primary-foreground);
    font-size: 12px;
    font-weight: 600;
    box-shadow: var(--glow-primary);
}

.clay-badge--success {
    background: var(--color-success);
    box-shadow: var(--glow-success);
}

.clay-badge--error {
    background: var(--color-error);
    box-shadow: var(--glow-error);
}

/* Enhanced Focus States */
.clay-input:focus,
.clay-btn:focus-visible,
.clay-btn-primary:focus-visible,
.clay-btn-circle:focus-visible {
    outline: none;
    box-shadow: var(--shadow-clay-card), var(--shadow-focus);
}

/* Enhanced Hover States */
.clay-card:hover {
    box-shadow: var(--shadow-hover);
}

/* Conversation Item Enhancement */
.conversation-link {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-decoration: none;
    color: var(--color-text-primary);
    transition: all 0.2s ease;
    background: transparent;
}

.conversation-link:hover {
    background: var(--color-muted);
    transform: translateX(4px);
}

.conversation-link:active {
    box-shadow: var(--shadow-clay-pressed);
    transform: translateX(2px) scale(0.99);
}

.conversation-link.active {
    background: var(--color-surface);
    color: var(--color-text-primary);
    box-shadow: var(--shadow-clay-pressed);
}

.conversation-link.active .conv-preview {
    color: var(--color-text-secondary);
}

.conv-name {
    font-weight: 600;
    font-size: 15px;
}

.conv-preview {
    font-size: 13px;
    color: var(--color-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Auth Logo Glow */
.auth-logo {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--gradient-primary);
    box-shadow: var(--glow-primary), var(--shadow-clay-card);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    animation: pulse-glow 2s infinite;
}

.auth-logo svg {
    width: 36px;
    height: 36px;
    color: var(--color-primary-foreground);
}

@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: var(--glow-primary), var(--shadow-clay-card);
    }

    50% {
        box-shadow: 0 0 30px hsla(250, 85%, 65%, 0.6), var(--shadow-clay-card);
    }
}

/* Message Read Receipts */
.msg-status {
    display: inline-flex;
    gap: 2px;
    margin-left: 6px;
    opacity: 0.7;
    width: 14px;
    height: 14px;
    align-items: center;
    justify-content: center;
}

.msg-status svg {
    width: 14px;
    height: 14px;
}

.msg-status--read svg {
    color: var(--color-primary);
    opacity: 1;
}

/* Typing Indicator */
.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 8px 14px;
    background: var(--color-message-received);
    border-radius: var(--radius-bubble);
    box-shadow: var(--shadow-clay-card);
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-text-secondary);
    animation: typing-bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-bounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-8px);
    }
}

/* File Attachment Preview */
.clay-file-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-clay-input);
    max-width: 280px;
}

.clay-file-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary-foreground);
}

.clay-file-info {
    flex: 1;
    min-width: 0;
}

.clay-file-name {
    font-weight: 500;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.clay-file-size {
    font-size: 12px;
    color: var(--color-text-secondary);
}

/* ========== Module 01 Design System ========== */

/* Clay Card hover (strong claymorphism) */
.clay-card:hover {
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}
.clay-card:hover {
    transform: translateY(-2px);
    box-shadow: 14px 14px 28px rgba(166, 180, 200, 0.45), -14px -14px 28px rgba(255, 255, 255, 0.85),
        inset 1px 1px 2px rgba(255, 255, 255, 0.5), inset -1px -1px 2px rgba(166, 180, 200, 0.1);
}
[data-theme="dark"] .clay-card:hover,
.dark .clay-card:hover {
    box-shadow: 14px 14px 28px rgba(0, 0, 0, 0.45), -14px -14px 28px rgba(255, 255, 255, 0.04),
        inset 1px 1px 2px rgba(255, 255, 255, 0.05), inset -1px -1px 2px rgba(0, 0, 0, 0.25);
}

/* Stat Card - Dashboard widgets (Module 01) */
.clay-stat-card {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-clay-card);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}
.clay-stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 3px 3px 6px rgba(0, 0, 0, 0.1), inset -3px -3px 6px rgba(255, 255, 255, 0.5);
}
[data-theme="dark"] .clay-stat-card .stat-icon,
.dark .clay-stat-card .stat-icon {
    box-shadow: inset 3px 3px 6px rgba(0, 0, 0, 0.3), inset -3px -3px 6px rgba(255, 255, 255, 0.03);
}
.clay-stat-card .stat-value {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-primary);
}
.clay-stat-card .stat-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    font-weight: var(--font-weight-medium);
}

/* Kanban Task Card (Module 01) */
.clay-task-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    margin-bottom: var(--space-3);
    cursor: grab;
    box-shadow: var(--shadow-clay-card);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
    position: relative;
}
.clay-task-card:hover {
    transform: translateY(-4px);
    box-shadow: 12px 12px 24px rgba(166, 180, 200, 0.35), -12px -12px 24px rgba(255, 255, 255, 0.85);
}
[data-theme="dark"] .clay-task-card:hover,
.dark .clay-task-card:hover {
    box-shadow: 12px 12px 24px rgba(0, 0, 0, 0.45), -12px -12px 24px rgba(255, 255, 255, 0.04);
}
.clay-task-card.dragging {
    opacity: 0.8;
    transform: rotate(3deg) scale(1.02);
    cursor: grabbing;
}
.clay-task-card .priority-strip {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}
.clay-task-card .priority-strip.urgent { background: var(--priority-urgent); }
.clay-task-card .priority-strip.high { background: var(--priority-high); }
.clay-task-card .priority-strip.medium { background: var(--priority-medium); }
.clay-task-card .priority-strip.low { background: var(--priority-low); }

/* Skeleton loader (Module 01) */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.skeleton {
    background: linear-gradient(90deg, var(--color-muted) 25%, var(--color-surface) 50%, var(--color-muted) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
    border-radius: var(--radius-md);
}

/* Status color utilities (Module 01) */
.text-status-pending { color: var(--status-pending); }
.text-status-in-progress { color: var(--status-in-progress); }
.text-status-completed { color: var(--status-completed); }
.text-status-cancelled { color: var(--status-cancelled); }
.text-status-overdue { color: var(--status-overdue); }
.bg-status-pending { background-color: var(--status-pending); }
.bg-status-in-progress { background-color: var(--status-in-progress); }
.bg-status-completed { background-color: var(--status-completed); }
.bg-status-cancelled { background-color: var(--status-cancelled); }
.bg-status-overdue { background-color: var(--status-overdue); }

/* Priority color utilities (Module 01) */
.text-priority-low { color: var(--priority-low); }
.text-priority-medium { color: var(--priority-medium); }
.text-priority-high { color: var(--priority-high); }
.text-priority-urgent { color: var(--priority-urgent); }
.bg-priority-low { background-color: var(--priority-low); }
.bg-priority-medium { background-color: var(--priority-medium); }
.bg-priority-high { background-color: var(--priority-high); }
.bg-priority-urgent { background-color: var(--priority-urgent); }