/**
 * ═══════════════════════════════════════════════════════════════════
 * LEXOR LUXURY REDESIGN - Part 1: Core & Variables
 * Inspired by minimalism, luxury, and professional aesthetics
 * ═══════════════════════════════════════════════════════════════════
 */

/* ==================== ENHANCED CSS VARIABLES ==================== */
:root[data-theme="dark"] {
    --bg-primary: #050508;
    --bg-secondary: #0f0f14;
    --bg-tertiary: #16161d;
    --bg-elevated: #1d1d26;
    --accent-glow: rgba(107, 124, 255, 0.5);
    --accent-glow-strong: rgba(107, 124, 255, 0.8);
    --shadow-elevated: 0 8px 32px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(107, 124, 255, 0.1);
    --shadow-luxury: 0 12px 48px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(107, 124, 255, 0.15);
    --shadow-glow: 0 0 20px var(--accent-glow), 0 0 40px var(--accent-glow);
    --transition-smooth: 400ms cubic-bezier(0.4, 0.0, 0.2, 1);
    --transition-bounce: 500ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

:root[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --bg-elevated: #ffffff;
    --accent-glow: rgba(85, 101, 221, 0.4);
    --accent-glow-strong: rgba(85, 101, 221, 0.6);
    --shadow-elevated: 0 8px 32px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(85, 101, 221, 0.06);
    --shadow-luxury: 0 12px 48px rgba(0, 0, 0, 0.12), 0 4px 16px rgba(85, 101, 221, 0.1);
    --shadow-glow: 0 0 20px var(--accent-glow), 0 0 40px var(--accent-glow);
    --transition-smooth: 400ms cubic-bezier(0.4, 0.0, 0.2, 1);
    --transition-bounce: 500ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ==================== HEADER ELEVATION ==================== */
.app-header {
    background: var(--bg-secondary);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12), 0 0 1px rgba(107, 124, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(107, 124, 255, 0.08);
    position: relative;
    z-index: 100;
}

#header-icon,
#header-logo {
    transition: all 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
}

#header-icon:hover {
    transform: scale(1.05) rotate(5deg);
    filter: drop-shadow(0 0 12px var(--accent-glow));
}

#header-logo:hover {
    transform: scale(1.02);
    filter: brightness(1.1) drop-shadow(0 0 8px var(--accent-glow));
}

/* ==================== LUXURY BUTTONS ==================== */
.primary-btn,
.ai-btn {
    background: linear-gradient(135deg, #4654be 0%, #515aad 100%);
    box-shadow: 0 4px 16px rgba(107, 124, 255, 0.35),
        0 2px 8px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border: none;
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.primary-btn::before,
.ai-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(42, 39, 100, 0);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.primary-btn:hover,
.ai-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 28px rgba(52, 70, 201, 0.5),
        0 4px 12px rgba(0, 0, 0, 0.3),
        0 0 24px rgba(24, 34, 109, 0.4),
        inset 0 1px 0 rgba(62, 68, 121, 0.3);
    background: linear-gradient(135deg, #34408d 0%, #2a3aa8 100%);
}

.primary-btn:hover::before,
.ai-btn:hover::before {
    width: 300px;
    height: 300px;
}

.primary-btn:active,
.ai-btn:active {
    transform: translateY(0) scale(0.98);
    transition-duration: 0.1s;
}

.secondary-btn,
.toolbar-btn {
    background: var(--bg-elevated);
    border: 1.5px solid rgba(107, 124, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.secondary-btn::after,
.toolbar-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(107, 124, 255, 0.15), transparent);
    transform: translate(-50%, -50%);
    transition: width 0.5s ease, height 0.5s ease;
}

.secondary-btn:hover,
.toolbar-btn:hover {
    transform: translateY(-2px) scale(1.02);
    border-color: var(--accent-primary);
    box-shadow: 0 6px 20px rgba(107, 124, 255, 0.25),
        0 0 20px rgba(107, 124, 255, 0.15);
    background: linear-gradient(135deg, var(--bg-elevated), var(--bg-tertiary));
}

.secondary-btn:hover::after,
.toolbar-btn:hover::after {
    width: 300px;
    height: 300px;
}

/* ==================== PANELS ==================== */
.panel {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.panel-header {
    background: linear-gradient(180deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border-bottom: 1px solid rgba(107, 124, 255, 0.05);
    backdrop-filter: blur(10px);
}

.panel-title {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    letter-spacing: 0.3px;
    transition: all 0.3s ease;
}

/* ==================== CARDS ==================== */
.document-card,
.summary-card,
.character-item,
.folder-item-card {
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
    border: 1.5px solid rgba(107, 124, 255, 0.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.document-card::before,
.summary-card::before,
.character-item::before,
.folder-item-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(107, 124, 255, 0.1), transparent);
    transition: left 0.6s ease;
}

.document-card:hover,
.summary-card:hover,
.character-item:hover,
.folder-item-card:hover {
    transform: translateY(-4px) scale(1.01);
    border-color: var(--accent-primary);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2),
        0 4px 16px rgba(107, 124, 255, 0.25),
        0 0 24px rgba(107, 124, 255, 0.15);
    background: linear-gradient(135deg, var(--bg-elevated) 0%, var(--bg-tertiary) 100%);
}

.document-card:hover::before,
.summary-card:hover::before,
.character-item:hover::before,
.folder-item-card:hover::before {
    left: 100%;
}

.document-card.active,
.character-item.selected {
    border-color: var(--accent-primary);
    box-shadow: 0 8px 24px rgba(107, 124, 255, 0.35),
        0 0 32px rgba(107, 124, 255, 0.2),
        inset 0 1px 0 rgba(107, 124, 255, 0.1);
    background: linear-gradient(135deg,
            rgba(107, 124, 255, 0.15) 0%,
            rgba(107, 124, 255, 0.08) 100%);
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100px) scale(0.8);
    }

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

@keyframes budgetPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.85;
    }
}

@keyframes tokenGlow {

    0%,
    100% {
        filter: brightness(1);
    }

    50% {
        filter: brightness(1.2);
    }
}

@keyframes spinGlow {

    0%,
    100% {
        box-shadow: 0 0 20px var(--accent-glow);
    }

    50% {
        box-shadow: 0 0 32px var(--accent-glow-strong);
    }
}

/* ==================== CONTEXT LIBRARY COMPACT REDESIGN ==================== */

/* Upload Slot */
.upload-slot-compact {
    background: var(--bg-tertiary);
    border: 1px dashed rgba(107, 124, 255, 0.2);
    border-radius: 8px;
    transition: all 0.3s ease;
    height: 48px;
    position: relative;
    overflow: hidden;
}

.upload-slot-compact:hover {
    background: var(--bg-elevated);
    border-color: var(--accent-primary);
    box-shadow: 0 4px 12px rgba(107, 124, 255, 0.15);
    transform: translateY(-1px);
}

.upload-label-compact {
    height: 100%;
    width: 100%;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.upload-slot-compact:hover .upload-label-compact {
    color: var(--text-primary);
}

/* Document List - Compact */
.documents-list-compact {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.document-compact-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid transparent;
    /* Reserve space for border */
    background: transparent;
    transition: all 0.2s ease;
    cursor: pointer;
    height: 36px;
    position: relative;
}

.document-compact-item:hover {
    background: var(--bg-elevated);
    border-color: rgba(107, 124, 255, 0.1);
}

.document-compact-item.active {
    background: rgba(107, 124, 255, 0.1);
    border-color: rgba(107, 124, 255, 0.3);
}

.document-compact-item.active .doc-name-compact {
    color: var(--accent-primary);
    font-weight: 600;
}

/* Checkbox */
.doc-checkbox-compact {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1.5px solid var(--border-medium);
    background: transparent;
    color: white;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    flex-shrink: 0;
}

.doc-checkbox-compact:hover {
    border-color: var(--accent-primary);
}

.doc-checkbox-compact.checked {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

/* Info Section */
.doc-info-compact {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
}

.doc-type-icon {
    font-size: 14px;
    opacity: 0.8;
    flex-shrink: 0;
}

.doc-name-compact {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.2s ease;
}

.document-compact-item:hover .doc-name-compact {
    color: var(--text-primary);
}

/* Actions (Visible on Hover) */
.doc-actions-compact {
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.2s ease;
}

.document-compact-item:hover .doc-actions-compact {
    opacity: 1;
    transform: translateX(0);
}

.doc-action-btn-mini {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.doc-action-btn-mini:hover {
    background: var(--accent-primary);
    color: white;
    transform: scale(1.1);
}

.doc-action-btn-mini.delete-doc:hover {
    background: var(--error);
}

/* Scrollbar refinement for the list */
.documents-list-compact::-webkit-scrollbar {
    width: 4px;
}