/* UI Components Styles */

/* Navigation */
.main-header {
    background-color: var(--bg-header);
    color: var(--text-main);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    border-bottom: 1px solid var(--border-subtle);
}

[data-theme="dark"] .main-header,
body.dark-mode .main-header {
    background: linear-gradient(135deg, var(--bg-header) 0%, var(--bg-body) 100%);
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.header-brand h1 {
    margin: 0;
    font-size: 1.5rem;
}

.header-brand h1 a {
    color: var(--text-main);
    text-decoration: none;
    transition: opacity var(--transition-normal);
}

.header-brand h1 a:hover {
    opacity: 0.9;
}

.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1001;
}

.mobile-menu-toggle span {
    width: 25px;
    height: 3px;
    background: var(--text-main);
    border-radius: 2px;
    transition: all var(--transition-normal);
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(8px, -8px);
}

.main-nav {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.nav-link {
    color: var(--text-main);
    text-decoration: none;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    position: relative;
}

.nav-link:hover {
    background-color: rgba(99, 102, 241, 0.1);
    transform: translateY(-2px);
}

.nav-link.active {
    background-color: rgba(99, 102, 241, 0.15);
    font-weight: 600;
    color: var(--color-primary);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 50%;
    transform: translateX(50%);
    width: 60%;
    height: 2px;
    background: var(--color-primary);
    border-radius: 2px;
}

.nav-link i {
    font-size: 1rem;
}

/* Mobile Navigation */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
    }

    .main-nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 280px;
        height: 100vh;
        background: var(--bg-header);
        flex-direction: column;
        align-items: stretch;
        padding: 4rem 1rem 1rem;
        box-shadow: var(--shadow-lg);
        transition: right var(--transition-normal);
        overflow-y: auto;
        z-index: 999;
    }

    .main-nav.active {
        right: 0;
    }

    .nav-link {
        width: 100%;
        padding: 1rem;
        border-radius: 8px;
        justify-content: flex-start;
    }

    .nav-link-text {
        display: inline;
    }

    /* Overlay for mobile menu */
    .nav-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 998;
    }

    .nav-overlay.active {
        display: block;
    }
}

@media (max-width: 480px) {
    .header-container {
        padding: 1rem;
    }

    .header-brand h1 {
        font-size: 1.2rem;
    }
}

/* Gamification Panel */
.gamification-panel {
    background: var(--bg-elevated);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
    border: 2px solid var(--border-color);
}

.gamification-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-soft);
    border-radius: 8px;
    transition: all var(--transition-normal);
    border: 2px solid transparent;
}

.stat-item:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    font-size: 2rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}

.stat-hp .stat-icon {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
}

.stat-xp .stat-icon {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
}

.stat-streak .stat-icon {
    background: linear-gradient(135deg, #e67e22, #d35400);
    color: white;
}

.stat-combo .stat-icon {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
    color: white;
}

.stat-content {
    flex: 1;
    min-width: 0;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--text-main);
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
}

.stat-unlimited {
    color: var(--color-secondary);
    font-size: 1.5rem;
}

.stat-separator {
    color: var(--text-muted);
    font-weight: normal;
}

.stat-unit {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: normal;
    margin-right: 0.25rem;
}

.stat-bar {
    width: 100%;
    height: 4px;
    background: var(--bg-secondary);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.stat-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width var(--transition-slow);
}

.stat-hp-bar {
    background: linear-gradient(90deg, #e74c3c, #c0392b);
}

.combo-multiplier {
    font-size: 0.75rem;
    color: var(--color-primary);
    margin-top: 0.25rem;
    font-weight: 600;
}

/* Stat Animation */
.stat-item.updating {
    animation: statPulse 0.5s ease;
}

@keyframes statPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Course Card Component */
.course-card {
    background: var(--bg-elevated);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
    border: 2px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.course-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--color-primary);
}

.course-card-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 1rem;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 3rem;
}

.course-card-header {
    margin-bottom: 1rem;
}

.course-card-title {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.course-card-description {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 1rem;
    flex: 1;
}

.course-card-progress {
    margin-bottom: 1rem;
}

.course-card-progress-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
}

.course-card-progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-soft);
    border-radius: 4px;
    overflow: hidden;
}

.course-card-progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    transition: width var(--transition-slow);
}

.course-card-actions {
    margin-top: auto;
    padding-top: 1rem;
}

.course-card-btn {
    width: 100%;
    padding: 0.75rem 1.5rem;
    background: var(--gradient-primary);
    color: var(--text-inverse);
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.course-card-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    opacity: 0.9;
}

.course-card-btn:active {
    transform: translateY(0);
}

/* Responsive */
@media (max-width: 768px) {
    .gamification-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stat-item {
        flex-direction: column;
        text-align: center;
    }
    
    .stat-icon {
        margin: 0 auto;
    }
}

@media (max-width: 480px) {
    .gamification-stats {
        grid-template-columns: 1fr;
    }
}

/* AI Chat Panel */
.ai-chat-panel {
    background: var(--bg-elevated);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 500px;
    max-height: 800px;
    border: 2px solid var(--border-color);
    overflow: hidden;
}

.chat-panel-header {
    padding: 1.5rem;
    background: var(--gradient-primary);
    color: var(--text-inverse);
    border-radius: 12px 12px 0 0;
}

.chat-header-content h3 {
    color: var(--text-inverse);
    margin: 0 0 0.5rem 0;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-header-content p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    margin: 0;
}

.chat-quota-indicator {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.quota-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.95);
}

.quota-value {
    font-weight: 600;
}

.quota-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.quota-bar-fill {
    height: 100%;
    background: var(--text-inverse);
    border-radius: 3px;
    transition: width var(--transition-slow);
}

.quota-bar-fill.low {
    background: var(--color-warning);
}

.quota-bar-fill.critical {
    background: var(--color-danger);
}

.chat-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--bg-secondary);
}

.chat-welcome-message {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.welcome-icon {
    font-size: 3rem;
    color: var(--color-primary);
    margin-bottom: 0.5rem;
}

.chat-welcome-message p {
    margin: 0;
    line-height: 1.6;
}

.chat-message-bubble {
    display: flex;
    gap: 0.75rem;
    max-width: 85%;
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message-bubble.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-message-bubble.assistant {
    align-self: flex-start;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
}

.chat-message-bubble.user .message-avatar {
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    color: #0b1120;
}

.chat-message-bubble.assistant .message-avatar {
    background: var(--bg-soft);
    border: 1px solid var(--border-subtle);
    color: var(--color-primary);
}

.message-content-wrapper {
    flex: 1;
    min-width: 0;
}

.message-content {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    line-height: 1.6;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.chat-message-bubble.user .message-content {
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    color: #0b1120;
    border-radius: 12px 12px 0 12px;
}

.chat-message-bubble.assistant .message-content {
    background: var(--bg-elevated);
    color: var(--text-main);
    border: 1px solid var(--border-subtle);
    border-radius: 12px 12px 12px 0;
}

.message-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    padding: 0 0.5rem;
    text-align: left;
}

.chat-message-bubble.user .message-time {
    text-align: right;
}

.chat-input-section {
    padding: 1rem;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-elevated);
}

.chat-quota-exceeded {
    padding: 1rem;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--text-main);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
}

.chat-input-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-input-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 20px;
    font-size: 1rem;
    font-family: inherit;
    background: var(--bg-input);
    color: var(--text-main);
    resize: none;
    max-height: 120px;
    overflow-y: auto;
    transition: border-color var(--transition-normal);
    direction: rtl;
}

.chat-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chat-send-button {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: var(--text-inverse);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-normal);
    flex-shrink: 0;
}

.chat-send-button:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

.chat-send-button:active:not(:disabled) {
    transform: scale(0.95);
}

.chat-send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-send-button.loading {
    pointer-events: none;
}

.chat-send-button.loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typingDot 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .ai-chat-panel {
        max-height: 600px;
        min-height: 400px;
    }
    
    .chat-message-bubble {
        max-width: 90%;
    }
}

