/* ============================================
   ProCode EduPulse — UI Components
   ============================================ */

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--brand-gradient);
    color: #fff;
    box-shadow: var(--shadow-md);
    border: 1px solid transparent;
}

.btn-primary:hover {
    background: var(--brand-gradient-hover);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: var(--shadow-md);
}

/* ── Enhanced Dark Mode Buttons ── */
[data-theme="dark"] .btn-primary {
    background: linear-gradient(135deg, #3B82F6 0%, #8B5CF6 100%);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

[data-theme="dark"] .btn-primary:hover {
    background: linear-gradient(135deg, #2563EB 0%, #7C3AED 100%);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
    background: var(--bg-elevated);
    border-color: var(--border-primary);
}

/* ── Enhanced Dark Mode Secondary Buttons ── */
[data-theme="dark"] .btn-secondary {
    background: rgba(41, 45, 54, 0.8);
    border-color: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
}

[data-theme="dark"] .btn-secondary:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
    color: var(--brand-primary);
}

.btn-success {
    background: #10B981;
    color: #fff;
    box-shadow: var(--shadow-md);
}

.btn-success:hover {
    background: #059669;
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-outline {
    background: transparent;
    color: var(--brand-primary-light);
    border: 1px solid var(--brand-primary);
}

.btn-outline:hover {
    background: rgba(0, 120, 212, 0.1);
    border-color: var(--brand-primary-light);
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-md);
}

.btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-xs);
}

.btn-lg {
    padding: var(--space-4) var(--space-8);
    font-size: var(--text-base);
    border-radius: var(--radius-lg);
}
.btn-full {
    width: 100%;
}

.btn-danger {
    background: var(--color-error);
    color: #fff;
}

.btn-danger:hover {
    background: #c0392b;
    box-shadow: 0 4px 12px rgba(225, 112, 85, 0.3);
}

.btn .btn-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ── Cards ── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    transition: all var(--transition-base);
    backdrop-filter: blur(10px);
}

.card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-primary);
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px);
}

/* ── Enhanced Dark Mode Cards ── */
[data-theme="dark"] .card {
    background: linear-gradient(135deg, rgba(31, 34, 41, 0.9) 0%, rgba(26, 29, 35, 0.9) 100%);
    border-color: rgba(255, 255, 255, 0.06);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .card:hover {
    background: linear-gradient(135deg, rgba(41, 45, 54, 0.95) 0%, rgba(31, 34, 41, 0.95) 100%);
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: 0 8px 30px rgba(59, 130, 246, 0.2);
}

.card-flat {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    transition: all var(--transition-base);
}

.card-flat:hover {
    border-color: var(--border-primary);
    box-shadow: var(--shadow-md);
}

.card-glass {
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    backdrop-filter: blur(20px);
    transition: all var(--transition-base);
}

.card-glass:hover {
    border-color: var(--border-primary);
    box-shadow: var(--shadow-md);
}

/* animation for large icons used on error/offline pages */
@keyframes float {
  0% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
  100% { transform: translateY(0); }
}
.error-offline-icon {
  animation: float 2s ease-in-out infinite;
}

/* ── Sidebar Modules ── */
.module-list {
    margin-bottom: var(--space-4);
}
.module-item {
    padding: var(--space-2) var(--space-4);
    font-weight: 600;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-2);
    position: relative;
}
.module-item.completed {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}
.module-item.completed::after {
    content: "\f00c";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    right: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-success);
    font-size: 0.9rem;
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-primary {
    background: rgba(0, 120, 212, 0.15);
    color: var(--brand-primary-light);
}

.badge-success {
    background: var(--color-success-light);
    color: var(--color-success);
}

.badge-warning {
    background: var(--color-warning-light);
    color: #E17055;
}

.badge-error {
    background: var(--color-error-light);
    color: var(--color-error);
}

/* ── Notification Bell ── */
.notif-bell {
    position: relative;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--border-subtle);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.notif-bell.has-unread {
    box-shadow: 0 0 0 0 rgba(108, 92, 231, 0.5);
    animation: notifPulse 1.6s infinite;
}

.notif-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--color-error);
    color: white;
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

@keyframes notifPulse {
    0% { box-shadow: 0 0 0 0 rgba(108, 92, 231, 0.5); }
    70% { box-shadow: 0 0 0 10px rgba(108, 92, 231, 0); }
    100% { box-shadow: 0 0 0 0 rgba(108, 92, 231, 0); }
}

/* ── Progress Bar ── */
.progress-track {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--brand-gradient);
    border-radius: var(--radius-full);
    transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

.progress-label {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

/* ── Input Fields ── */
.input-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.input-group label {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-secondary);
}

.input {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.input:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(0, 120, 212, 0.15);
}

/* ── Enhanced Dark Mode Input Fields ── */
[data-theme="dark"] .input {
    background: rgba(41, 45, 54, 0.6);
    border-color: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

[data-theme="dark"] .input:focus {
    background: rgba(41, 45, 54, 0.8);
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

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

.textarea {
    min-height: 120px;
    resize: vertical;
}

/* ── Tabs ── */
.tabs {
    display: flex;
    gap: var(--space-1);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: var(--space-1);
}

.tab {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    cursor: pointer;
}

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

.tab.active {
    background: var(--bg-elevated);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal-backdrop);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    max-width: 500px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    transform: scale(0.9) translateY(20px);
    transition: transform var(--transition-spring);
    z-index: var(--z-modal);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

/* ── Enhanced Dark Mode Modal ── */
[data-theme="dark"] .modal {
    background: linear-gradient(135deg, rgba(20, 23, 28, 0.95) 0%, rgba(26, 29, 35, 0.95) 100%);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .modal-overlay {
    background: rgba(0, 0, 0, 0.8);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-6);
}

.modal-title {
    font-size: var(--text-xl);
    font-weight: var(--font-bold);
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ── Toast / Notification ── */
.toast-container {
    position: fixed;
    top: calc(var(--navbar-height) + var(--space-4));
    right: var(--space-4);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-4) var(--space-5);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.4s ease forwards;
    min-width: 300px;
    max-width: 420px;
}

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

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

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

.toast-info {
    border-left: 3px solid var(--color-info);
}

.toast-icon {
    font-size: var(--text-xl);
    flex-shrink: 0;
}

.toast-message {
    font-size: var(--text-sm);
    color: var(--text-primary);
    flex: 1;
}

/* ── Tooltip ── */
.tooltip-wrapper {
    position: relative;
}

.tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-size: var(--text-xs);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    box-shadow: var(--shadow-md);
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition-fast);
    z-index: var(--z-tooltip);
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--bg-elevated);
}

.tooltip-wrapper:hover .tooltip {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* ── Accordion ── */
.accordion-item {
    border-bottom: 1px solid var(--border-subtle);
}

.accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) 0;
    cursor: pointer;
    color: var(--text-primary);
    font-weight: var(--font-medium);
    transition: color var(--transition-fast);
}

.accordion-header:hover {
    color: var(--brand-primary-light);
}

.accordion-icon {
    transition: transform var(--transition-base);
}

.accordion-item.active .accordion-icon {
    transform: rotate(180deg);
}

.accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-slow);
}

.accordion-item.active .accordion-body {
    max-height: 500px;
}

.accordion-content {
    padding-bottom: var(--space-4);
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

/* ── Markdown Editor Preview ── */
.markdown-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
    align-items: stretch;
}

.markdown-editor .textarea {
    min-height: 220px;
}

.markdown-preview {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    min-height: 220px;
    overflow: auto;
    color: var(--text-secondary);
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3,
.markdown-preview h4 {
    color: var(--text-primary);
    margin: 0 0 var(--space-3);
}

.markdown-preview p {
    margin-bottom: var(--space-3);
    line-height: 1.6;
}

.markdown-preview pre {
    background: var(--bg-tertiary);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    overflow: auto;
}

.markdown-preview code {
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);
    font-size: 0.9em;
}

@media (max-width: 900px) {
    .markdown-split {
        grid-template-columns: 1fr;
    }
}

/* ── Skeleton Loader ── */
.skeleton {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
}

.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* ── Divider ── */
.divider {
    height: 1px;
    background: var(--border-subtle);
    margin: var(--space-6) 0;
}

/* ── Avatar ── */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--brand-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-sm);
    font-weight: var(--font-bold);
    color: #fff;
    flex-shrink: 0;
}

/* ── Back to Top ── */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--brand-gradient);
    color: #fff;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: 200;
    cursor: pointer;
}

.back-to-top.visible {
    opacity: 1;
    pointer-events: auto;
}
/* ── Search Highlighting ── */
mark.search-highlight {
    background: rgba(0, 120, 212, 0.25);
    color: var(--brand-primary-light);
    border-radius: 2px;
    padding: 0 2px;
    font-weight: 600;
}

/* ── Breadcrumbs ── */
.breadcrumb-nav {
    margin-bottom: var(--space-4);
}
.breadcrumb-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: var(--text-sm);
}
.breadcrumb-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-muted);
}
.breadcrumb-item a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}
.breadcrumb-item a:hover {
    color: var(--brand-primary-light);
}
.breadcrumb-item.active {
    color: var(--text-primary);
    font-weight: 600;
}
.breadcrumb-separator {
    color: var(--text-muted);
    opacity: 0.5;
    font-size: 0.8rem;
}

.shortcuts-tooltip.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.shortcuts-tooltip-title {
    font-weight: var(--font-bold);
    font-size: var(--text-sm);
    margin-bottom: var(--space-3);
    color: var(--text-primary);
}

.shortcuts-tooltip-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-1) 0;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.shortcuts-tooltip-row kbd {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 2px 6px;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text-primary);
}

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: var(--text-xs);
}

.avatar-lg {
    width: 56px;
    height: 56px;
    font-size: var(--text-xl);
}

/* ── Tag ── */
.tag {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: var(--space-16) var(--space-6);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: var(--space-4);
}

.empty-state-title {
    font-size: var(--text-xl);
    font-weight: var(--font-semibold);
    margin-bottom: var(--space-2);
}

.empty-state-text {
    color: var(--text-muted);
    max-width: 400px;
    margin: 0 auto;
}

/* ── Professional Container Variations ── */
.container-sidebar {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: var(--space-6);
    min-height: 100vh;
}

.sidebar-admin {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    padding: var(--space-6);
    position: sticky;
    top: var(--navbar-height);
    height: calc(100vh - var(--navbar-height));
    overflow-y: auto;
}

/* ── Card Variations ── */
.card-hover-lift {
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.card-hover-lift:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-xl);
}

.card-border-gradient {
    position: relative;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.card-border-gradient::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: var(--radius-lg);
    background: var(--brand-gradient);
    z-index: -1;
}

/* ── Section Header Professional ── */
.section-header-professional {
    margin-bottom: var(--space-12);
    position: relative;
}

.section-header-professional::after {
    content: '';
    position: absolute;
    bottom: -var(--space-4);
    left: 0;
    width: 60px;
    height: 4px;
    background: var(--brand-gradient);
    border-radius: var(--radius-full);
}

/* ── Divider Variations ── */
.divider {
    border: none;
    height: 1px;
    background: var(--border-subtle);
    margin: var(--space-6) 0;
}

.divider-gradient {
    height: 2px;
    background: var(--brand-gradient);
    border-radius: var(--radius-full);
    margin: var(--space-8) 0;
}

/* ── List Items Professional ── */
.list-item-professional {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
}

.list-item-professional:hover {
    background: var(--bg-tertiary);
    transform: translateX(2px);
}

/* ── Stats Container ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    text-align: center;
    transition: all var(--transition-base);
}

.stat-card:hover {
    border-color: var(--border-primary);
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.stat-card-value {
    font-size: 2rem;
    font-weight: 800;
    background: var(--brand-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--space-2);
}

.stat-card-label {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

/* ── Mobile Overrides ── */
@media (max-width: 480px) {
    .card, .card-glass, .card-flat {
        padding: var(--space-4);
    }
    .modal {
        padding: var(--space-6);
    }
    .btn {
        padding: var(--space-2) var(--space-4);
        font-size: var(--text-xs);
    }
    .btn-lg {
        padding: var(--space-3) var(--space-6);
        font-size: var(--text-sm);
    }
}

/* ── Visibility Utilities ── */
.desktop-only {
    display: flex !important;
}

.mobile-only {
    display: none !important;
}

@media (max-width: 1150px) {
    .desktop-only {
        display: none !important;
    }
    .mobile-only {
        display: flex !important;
    }
}