/* ===== Enhanced Theme — Animations & Micro-interactions ===== */
/* Extends Conicorn Design System — loads after style.css */

/* === 1. Animation Keyframes === */

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

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

@keyframes slideOutRight {
    from { transform: translateX(0); }
    to { transform: translateX(100%); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

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

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-8px); opacity: 1; }
}

@keyframes glowPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(131, 154, 255, 0.3); }
    50% { box-shadow: 0 0 0 6px rgba(131, 154, 255, 0); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}

@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

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

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

/* === 2. Button Micro-interactions === */

.btn-primary:hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 16px rgba(131, 154, 255, 0.3) !important;
}

.btn-primary:active {
    transform: scale(0.97) !important;
}

.btn-secondary:hover {
    transform: translateY(-1px) !important;
}

.btn-secondary:active {
    transform: scale(0.97) !important;
}

.btn-small:hover {
    transform: translateY(-1px);
}

.btn-small:active {
    transform: scale(0.97);
}

/* Button Loading Spinner */
.btn-loading {
    position: relative;
    pointer-events: none !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    top: 50%;
    left: 50%;
    margin: -7px 0 0 6px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* === 3. Input Enhancements === */

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
    border-color: var(--border-focus) !important;
    box-shadow: 0 0 0 3px rgba(131, 154, 255, 0.2), inset 0 0 8px rgba(131, 154, 255, 0.05) !important;
    animation: glowPulse 2s infinite;
}

/* Placeholder fade on focus */
input:focus::placeholder,
textarea:focus::placeholder {
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

/* Error state shake */
.input-error {
    border-color: var(--text-error) !important;
    animation: shake 0.3s ease;
}

/* === 4. Navigation Enhancements === */

.top-nav {
    animation: fadeIn 0.3s ease;
}

.nav-buttons button {
    transition: all 0.2s ease;
}

.nav-buttons button:hover {
    transform: translateY(-1px);
}

.nav-buttons button:active {
    transform: scale(0.95);
}

/* === 5. Status Indicator Breathing === */

.status-idle {
    transition: all 0.3s ease;
}

.status-loading {
    animation: pulse 1s infinite;
}

.status-success {
    animation: fadeIn 0.3s ease, glowPulse 2s ease 1;
}

.status-error {
    animation: fadeIn 0.3s ease;
}

/* === 6. Panel Entrance Animations === */

.control-section {
    animation: fadeInUp 0.3s ease-out;
}

.output-section {
    animation: fadeInUp 0.3s ease-out 0.1s both;
}

.input-section {
    animation: fadeInUp 0.3s ease-out 0.2s both;
}

.history-section {
    animation: fadeInUp 0.3s ease-out 0.15s both;
}

/* === 7. Progress Bar Shimmer === */

.progress-fill {
    position: relative;
    background: var(--holo-gradient) !important;
    background-size: 200% 100% !important;
    animation: progressShimmer 2s linear infinite !important;
    transition: width 0.3s ease !important;
}

/* === 8. Typing Indicator Enhancement === */

.typing-indicator {
    display: inline-flex !important;
    gap: 5px;
    padding: 8px 12px;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--holo-100);
    animation: typingBounce 1.2s infinite ease-in-out;
}

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

/* === 9. Welcome Screen Enhancement === */

.chat-welcome {
    text-align: center;
    color: var(--text-muted);
    padding: 60px 20px;
    font-size: var(--font-size-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    animation: fadeInUp 0.5s ease-out;
    gap: 12px;
}

.chat-welcome p {
    animation: fadeInUp 0.5s ease-out 0.15s both;
}

/* === 10. Toast Notification System === */

.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    min-width: 280px;
    max-width: 400px;
    pointer-events: auto;
    cursor: pointer;
    animation: slideInRight 0.25s ease-out;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.toast.removing {
    animation: slideOutRight 0.25s ease-in forwards;
}

.toast-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.toast.toast-success { border-left: 3px solid var(--text-success); }
.toast.toast-error { border-left: 3px solid var(--text-error); }
.toast.toast-warning { border-left: 3px solid var(--text-warning); }
.toast.toast-info { border-left: 3px solid var(--holo-100); }

/* === 11. Empty State === */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    animation: fadeIn 0.3s ease-out;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    animation: float 3s ease-in-out infinite;
    opacity: 0.6;
}

.empty-state-text {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.empty-state-action {
    font-size: var(--font-size-xs);
    color: var(--text-username);
}

/* === 12. Error Boundary Card === */

.error-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    background: var(--bg-error);
    border: 1px solid var(--text-error);
    border-radius: var(--radius-md);
    animation: fadeInUp 0.3s ease-out;
}

.error-card-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.error-card-text {
    font-size: var(--font-size-sm);
    color: var(--text-error);
    margin-bottom: 1rem;
}

.error-card button {
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-pill);
    background: var(--text-error);
    color: white;
    border: none;
    cursor: pointer;
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: all 0.2s ease;
}

.error-card button:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

/* === 13. Code Block Enhancements === */

.chat-content pre {
    position: relative;
}

.chat-content pre:hover .code-copy-btn {
    opacity: 1;
}

.code-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-btn-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 0.7rem;
    opacity: 0;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
}

.code-copy-btn:hover {
    background: var(--bg-btn-secondary-hover);
    color: var(--text-primary);
}

/* === 14. Cursor for Streaming === */

.streaming-cursor::after {
    content: '|';
    animation: cursorBlink 0.8s infinite;
    color: var(--holo-100);
    font-weight: bold;
}

/* === 15. History Item Enhancements === */

.history-item {
    animation: fadeInUp 0.25s ease-out both;
}

.history-item:nth-child(1) { animation-delay: 0s; }
.history-item:nth-child(2) { animation-delay: 0.03s; }
.history-item:nth-child(3) { animation-delay: 0.06s; }
.history-item:nth-child(4) { animation-delay: 0.09s; }
.history-item:nth-child(5) { animation-delay: 0.12s; }
.history-item:nth-child(n+6) { animation-delay: 0.15s; }

.history-item:hover {
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* === 16. Page-specific: Login Page === */

.auth-container {
    animation: fadeInUp 0.4s ease-out;
}

.auth-container::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    background: var(--holo-gradient);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
}

.auth-container:hover::after {
    opacity: 0.3;
}

.input-group input:focus {
    animation: glowPulse 2s infinite;
}

/* === 17. Page-specific: Profile Page === */

.profile-card {
    animation: fadeInUp 0.3s ease-out both;
}

.profile-card:nth-child(2) { animation-delay: 0.1s; }
.profile-card:nth-child(3) { animation-delay: 0.2s; }

/* === 18. Page-specific: JK Manor === */

.jk-radar-card {
    animation: fadeInUp 0.3s ease-out both;
}

.jk-status-online {
    animation: pulse 2s infinite;
}

.jk-queue-progress {
    position: relative;
    overflow: hidden;
}

.jk-queue-progress::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(131,154,255,0.15), transparent);
    animation: shimmer 1.5s ease-in-out infinite;
}

/* === 19. Smooth Theme Transition === */

html[data-theme-transitioning] * {
    transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease !important;
}
