/**
 * Verbi - Components CSS
 * Buttons, Cards, Forms, Badges, Progress
 */

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    line-height: 1;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    border: none;
    white-space: nowrap;
}

.btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Primary button */
.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Secondary button */
.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-text-dim);
}

/* Accent button */
.btn-accent {
    background: var(--color-accent);
    color: white;
}

.btn-accent:hover {
    background: var(--color-accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Ghost button */
.btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
}

.btn-ghost:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

/* Danger button */
.btn-danger {
    background: var(--color-error);
    color: white;
}

.btn-danger:hover {
    background: var(--color-error);
    opacity: 0.9;
}

/* Sizes */
.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);
}

.btn-xl {
    padding: var(--space-5) var(--space-10);
    font-size: var(--text-lg);
}

/* Full width */
.btn-full {
    width: 100%;
}

/* Disabled state */
.btn:disabled,
.btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Icon only */
.btn-icon {
    padding: var(--space-3);
}

.btn-icon.btn-sm {
    padding: var(--space-2);
}

.btn-icon.btn-lg {
    padding: var(--space-4);
}

/* ============================================
   CARDS
   ============================================ */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    transition: all var(--transition-normal);
}

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

.card-header {
    margin-bottom: var(--space-4);
}

.card-title {
    font-size: var(--text-xl);
    font-weight: var(--font-semibold);
    margin-bottom: var(--space-1);
}

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

.card-body {
    margin-bottom: var(--space-4);
}

.card-footer {
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: var(--space-3);
}

/* Card variants */
.card-interactive {
    cursor: pointer;
}

.card-glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
}

.card-glow {
    box-shadow: var(--shadow-glow);
}

/* Stat card */
.stat-card {
    text-align: center;
    padding: var(--space-8);
}

.stat-card-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto var(--space-4);
    padding: var(--space-3);
    background: var(--color-primary-muted);
    border-radius: var(--radius-lg);
    color: var(--color-primary);
}

.stat-card-icon svg {
    width: 100%;
    height: 100%;
}

.stat-card-value {
    font-family: var(--font-display);
    font-size: var(--text-4xl);
    font-weight: var(--font-bold);
    color: var(--color-text);
    line-height: 1;
    margin-bottom: var(--space-2);
}

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

/* Feature card */
.feature-card {
    padding: var(--space-8);
    text-align: center;
}

.feature-card-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--space-6);
    padding: var(--space-4);
    background: var(--color-primary-muted);
    border-radius: var(--radius-xl);
    color: var(--color-primary);
}

.feature-card-icon svg {
    width: 100%;
    height: 100%;
}

.feature-card-title {
    font-size: var(--text-xl);
    font-weight: var(--font-semibold);
    margin-bottom: var(--space-3);
}

.feature-card-text {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    line-height: var(--leading-relaxed);
}

/* Plan card */
.plan-card {
    padding: var(--space-8);
    position: relative;
    overflow: hidden;
}

.plan-card.featured {
    border-color: var(--color-primary);
    transform: scale(1.02);
}

.plan-card.featured::before {
    content: 'Popular';
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    background: var(--color-primary);
    color: white;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
}

.plan-card-level {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--color-primary);
    font-weight: var(--font-semibold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    margin-bottom: var(--space-2);
}

.plan-card-price {
    font-family: var(--font-display);
    font-size: var(--text-5xl);
    font-weight: var(--font-bold);
    margin-bottom: var(--space-1);
}

.plan-card-price span {
    font-size: var(--text-lg);
    font-weight: var(--font-normal);
    color: var(--color-text-muted);
}

.plan-card-period {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-6);
}

.plan-card-features {
    list-style: none;
    padding: 0;
    margin-bottom: var(--space-6);
    text-align: left;
}

.plan-card-features li {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) 0;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.plan-card-features li svg {
    width: 16px;
    height: 16px;
    color: var(--color-success);
    flex-shrink: 0;
}

/* ============================================
   FORM ELEMENTS
   ============================================ */

.form-group {
    margin-bottom: var(--space-6);
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--color-text);
    margin-bottom: var(--space-2);
}

.form-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    color: var(--color-text);
    font-size: var(--text-base);
    transition: all var(--transition-fast);
}

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

.form-input:hover {
    border-color: var(--color-text-dim);
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-muted);
}

.form-input.error {
    border-color: var(--color-error);
}

.form-input.error:focus {
    box-shadow: 0 0 0 3px var(--color-error-bg);
}

.form-hint {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin-top: var(--space-2);
}

.form-error {
    font-size: var(--text-xs);
    color: var(--color-error);
    margin-top: var(--space-2);
}

/* Textarea */
.form-textarea {
    min-height: 120px;
    resize: vertical;
}

/* Select */
.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%237B82A8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-3) center;
    background-size: 18px;
    padding-right: var(--space-10);
}

/* Checkbox & Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
}

.form-check-input {
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    cursor: pointer;
    transition: all var(--transition-fast);
    appearance: none;
}

.form-check-input:checked {
    background: var(--color-primary);
    border-color: var(--color-primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
}

.form-check-label {
    font-size: var(--text-sm);
    color: var(--color-text);
}

/* ============================================
   BADGES & TAGS
   ============================================ */

.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);
    background: var(--color-primary-muted);
    color: var(--color-primary);
}

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

.badge-warning {
    background: var(--color-gold-muted);
    color: var(--color-gold);
}

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

.badge-muted {
    background: var(--color-surface-hover);
    color: var(--color-text-muted);
}

/* Level badges */
.level-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    font-weight: var(--font-bold);
    border-radius: var(--radius-lg);
    color: white;
}

.level-badge.a1 { background: #4ADE80; }
.level-badge.a2 { background: #22D3EE; }
.level-badge.b1 { background: #5B6BFF; }
.level-badge.b2 { background: #A78BFA; }
.level-badge.c1 { background: #F472B6; }
.level-badge.c2 { background: var(--color-gold); }

/* Article badges */
.article-badge {
    display: inline-block;
    padding: var(--space-1) var(--space-2);
    font-family: var(--font-german);
    font-size: var(--text-sm);
    font-weight: var(--font-bold);
    border-radius: var(--radius-md);
}

.article-badge.der {
    background: rgba(59, 130, 246, 0.2);
    color: #60A5FA;
}

.article-badge.die {
    background: rgba(236, 72, 153, 0.2);
    color: #F472B6;
}

.article-badge.das {
    background: rgba(34, 197, 94, 0.2);
    color: #4ADE80;
}

/* ============================================
   PROGRESS BARS
   ============================================ */

.progress {
    height: 8px;
    background: var(--color-surface-hover);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: progress-shine 2s ease-in-out infinite;
}

@keyframes progress-shine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

/* Circular progress */
.circular-progress {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

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

.circular-progress-bg {
    stroke: var(--color-surface-hover);
}

.circular-progress-fill {
    stroke: var(--color-primary);
    stroke-linecap: round;
    transition: stroke-dashoffset var(--transition-slow);
}

.circular-progress-text {
    position: absolute;
    font-family: var(--font-mono);
    font-size: var(--text-lg);
    font-weight: var(--font-bold);
}

/* XP bar in lesson */
.xp-bar {
    height: 4px;
    background: var(--color-surface-hover);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.xp-bar-fill {
    height: 100%;
    background: var(--gradient-gold);
    width: 0;
    animation: xp-fill 1s ease-out forwards;
}

@keyframes xp-fill {
    to { width: var(--target-width, 100%); }
}

/* ============================================
   MODALS
   ============================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-2xl);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95) translateY(20px);
    transition: transform var(--transition-normal);
}

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

.modal-header {
    padding: var(--space-6);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

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

.modal-close:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

.modal-body {
    padding: var(--space-6);
}

.modal-footer {
    padding: var(--space-6);
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
}

/* ============================================
   TOASTS & ALERTS
   ============================================ */

.toast-container {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: toast-in 0.3s ease-out;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

@keyframes toast-out {
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.toast-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.toast-success .toast-icon { color: var(--color-success); }
.toast-error .toast-icon { color: var(--color-error); }
.toast-warning .toast-icon { color: var(--color-warning); }
.toast-info .toast-icon { color: var(--color-info); }

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

/* Alert banners */
.alert {
    padding: var(--space-4) var(--space-6);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.alert-success {
    background: var(--color-success-bg);
    color: var(--color-success);
    border: 1px solid var(--color-success);
}

.alert-error {
    background: var(--color-error-bg);
    color: var(--color-error);
    border: 1px solid var(--color-error);
}

.alert-warning {
    background: var(--color-gold-muted);
    color: var(--color-gold);
    border: 1px solid var(--color-gold);
}

.alert svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* ============================================
   AVATARS
   ============================================ */

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    font-weight: var(--font-bold);
    color: white;
    flex-shrink: 0;
}

.avatar-xs { width: 24px; height: 24px; font-size: var(--text-xs); }
.avatar-sm { width: 32px; height: 32px; font-size: var(--text-sm); }
.avatar-md { width: 40px; height: 40px; font-size: var(--text-base); }
.avatar-lg { width: 56px; height: 56px; font-size: var(--text-xl); }
.avatar-xl { width: 80px; height: 80px; font-size: var(--text-3xl); }

/* Avatar group */
.avatar-group {
    display: flex;
}

.avatar-group .avatar {
    margin-left: -8px;
    border: 2px solid var(--color-surface);
}

.avatar-group .avatar:first-child {
    margin-left: 0;
}

/* ============================================
   LOADING STATES
   ============================================ */

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

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

.skeleton {
    background: linear-gradient(90deg, var(--color-surface) 25%, var(--color-surface-hover) 50%, var(--color-surface) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

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

/* ============================================
   TABLES
   ============================================ */

.table-container {
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: var(--color-surface);
    padding: var(--space-4);
    text-align: left;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
}

.data-table td {
    padding: var(--space-4);
    border-bottom: 1px solid var(--color-border-light);
    font-size: var(--text-sm);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: var(--color-surface-hover);
}

.data-table .actions {
    display: flex;
    gap: var(--space-2);
}

/* ============================================
   DROPDOWNS
   ============================================ */

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + var(--space-2));
    left: 0;
    min-width: 180px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-2);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--transition-fast);
}

.dropdown.open .dropdown-menu,
.dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.dropdown-item:hover {
    background: var(--color-surface-hover);
}

.dropdown-item svg {
    width: 16px;
    height: 16px;
    color: var(--color-text-muted);
}

/* ============================================
   TABS
   ============================================ */

.tabs {
    display: flex;
    gap: var(--space-1);
    border-bottom: 1px solid var(--color-border);
    margin-bottom: var(--space-6);
}

.tab {
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--color-text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all var(--transition-fast);
    cursor: pointer;
}

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

.tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

/* ============================================
   ACCORDION
   ============================================ */

.accordion {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    overflow: hidden;
}

.accordion-item {
    border-bottom: 1px solid var(--color-border);
}

.accordion-item:last-child {
    border-bottom: none;
}

.accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-6);
    background: var(--color-surface);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.accordion-header:hover {
    background: var(--color-surface-hover);
}

.accordion-title {
    font-weight: var(--font-medium);
    color: var(--color-text);
}

.accordion-icon {
    width: 20px;
    height: 20px;
    color: var(--color-text-muted);
    transition: transform var(--transition-normal);
}

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

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

.accordion-item.open .accordion-content {
    max-height: 500px;
}

.accordion-body {
    padding: var(--space-4) var(--space-6);
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
}