/* ============================================
   StudyHub - UI Components (Redesigned)
   ============================================ */

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 0.625rem 1.25rem;
    font-size: var(--text-sm);
    font-weight: 500;
    border-radius: var(--radius-full);
    /* Pill shape */
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
    user-select: none;
    line-height: 1.5;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
}

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

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

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

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding-left: var(--space-sm);
    padding-right: var(--space-sm);
}

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

.btn-icon {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border-radius: var(--radius-full);
}

/* === CARDS === */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

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

.card-header {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.card-icon {
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface-hover);
    color: var(--color-primary);
    border-radius: var(--radius-lg);
    flex-shrink: 0;
    transition: all var(--transition-base);
}

.card:hover .card-icon {
    background: var(--color-primary);
    color: white;
}

.card-icon svg {
    width: 1.5rem;
    height: 1.5rem;
}

.card-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.card-description {
    color: var(--text-secondary);
    font-size: var(--text-sm);
    line-height: 1.6;
}

/* === INPUTS === */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-label {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
}

.input {
    width: 100%;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    font-family: inherit;
    font-size: var(--text-sm);
    transition: all var(--transition-fast);
}

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

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

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

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

/* === FILE INPUT === */
.file-input {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
    background: var(--bg-surface);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.file-input:hover,
.file-input.dragover {
    border-color: var(--color-primary);
    background: var(--color-primary-soft);
}

.file-input-icon {
    color: var(--text-muted);
    margin-bottom: var(--space-md);
    transition: color var(--transition-fast);
}

.file-input:hover .file-input-icon {
    color: var(--color-primary);
}

/* === BADGES === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.025em;
    text-transform: uppercase;
}

.badge-primary {
    background: var(--color-primary-soft);
    color: var(--color-primary);
    border: 1px solid rgba(129, 140, 248, 0.2);
}

/* === MODALS === */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    z-index: var(--z-modal-backdrop);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
}

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

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -45%) scale(0.95);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-2xl);
    padding: var(--space-xl);
    width: 90%;
    max-width: 500px;
    z-index: var(--z-modal);
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-xl);
}

.modal.active {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

/* === LOADING === */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* === ALERTS === */
.alert {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    border-left: 4px solid;
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.alert-info {
    border-color: var(--color-primary);
    background: var(--color-primary-soft);
}

.alert-error {
    border-color: var(--color-danger);
    background: rgba(248, 113, 113, 0.1);
}

/* ============================================
   HERO SECTION - Premium Identity
   ============================================ */
.hero {
    text-align: center;
    padding: 0 var(--space-md) 0.5rem;
    margin-bottom: 0.25rem;
    position: relative;
}

.hero::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--color-primary-soft);
    border: 1px solid rgba(129, 140, 248, 0.2);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: var(--space-lg);
    animation: fadeIn 0.6s ease-out;
}

.hero-badge-dot {
    width: 6px;
    height: 6px;
    background: var(--color-accent);
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

.hero-title {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
    animation: fadeIn 0.5s ease-out 0.1s both;
}

.hero-subtitle {
    font-size: clamp(0.875rem, 1.5vw, 1rem);
    color: var(--text-secondary);
    max-width: 400px;
    margin: 0 auto var(--space-md);
    line-height: 1.5;
    animation: fadeIn 0.5s ease-out 0.2s both;
}

.hero-cta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
    animation: fadeIn 0.6s ease-out 0.3s both;
}

.hero-hint {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

/* Larger primary button */
.btn-lg {
    padding: 1rem 2rem;
    font-size: 1rem;
    gap: 0.75rem;
}

/* ============================================
   FEATURED CARDS - Premium Hierarchy
   ============================================ */
.tools-section {
    margin-bottom: var(--space-xl);
}

.section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: var(--space-md);
    padding-left: 2px;
}

/* ============================================
   CATEGORY CHIPS
   ============================================ */
.category-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: var(--space-md);
    justify-content: center;
}

.chip {
    padding: 0.375rem 0.75rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.chip:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.chip.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

/* ============================================
   FEATURED CARD SIGNALS & CTA
   ============================================ */
.featured-card-signals {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.signal {
    font-size: 0.6rem;
    color: #6ee7b7;
    font-weight: 400;
    opacity: 0.85;
}

[data-theme="light"] .signal {
    color: #059669;
    opacity: 1;
}

.featured-card-cta {
    position: absolute;
    right: var(--space-lg);
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-primary);
    opacity: 0;
    transition: all 0.2s ease;
}

.featured-card:hover .featured-card-cta {
    opacity: 1;
    right: var(--space-md);
}

.featured-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--space-lg);
    padding: var(--space-lg);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.04) 0%, rgba(139, 92, 246, 0.04) 100%);
    border-radius: var(--radius-2xl);
    border: 1px solid var(--border-color);
}

/* Light mode: individual cards strong, no container */
[data-theme="light"] .featured-grid {
    background: transparent;
    border: none;
    padding: 0;
}

[data-theme="light"] .featured-card {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .featured-card:hover {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
    border-color: var(--color-primary);
}

.featured-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    padding: var(--space-xl);
    min-height: 120px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-left: 2px solid transparent;
    border-radius: var(--radius-2xl);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.featured-card:hover {
    border-left-color: var(--color-primary);
    border-left-width: 4px;
    transform: translateY(-6px) scale(1.01);
    box-shadow:
        0 16px 32px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(167, 139, 250, 0.15);
}

.featured-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.3s;
}

.featured-card:hover {
    border-color: var(--color-primary);
    transform: translateY(-8px) scale(1.02);
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(99, 102, 241, 0.2),
        0 0 60px rgba(99, 102, 241, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.featured-card:hover::before {
    opacity: 1;
}

.featured-card-icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-primary);
    border-radius: var(--radius-xl);
    color: white;
    flex-shrink: 0;
    transition: transform 0.3s, box-shadow 0.3s;
}

.featured-card:hover .featured-card-icon {
    transform: scale(1.15) rotate(-5deg);
    box-shadow: 0 12px 30px rgba(99, 102, 241, 0.5);
}

.featured-card-icon svg {
    width: 28px;
    height: 28px;
}

.featured-card-content {
    flex: 1;
}

.featured-card-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.featured-card-tagline {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.featured-card-action {
    flex-shrink: 0;
}

.featured-card-action .btn {
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.3s;
}

.featured-card:hover .featured-card-action .btn {
    opacity: 1;
    transform: translateX(0);
}

.featured-card-glow {
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15), transparent 60%);
    opacity: 0;
    transition: opacity 0.5s;
    pointer-events: none;
}

.featured-card:hover .featured-card-glow {
    opacity: 1;
}

/* ============================================
   REGULAR CARDS - Refined
   ============================================ */
.card {
    cursor: pointer;
}

.card:hover .card-icon {
    transform: scale(1.1);
}

.coming-soon {
    opacity: 0.6;
    pointer-events: none;
}

.coming-soon .card {
    border-style: dashed;
}

/* ============================================
   AD CONTAINERS - Professional Integration
   ============================================ */
.ad-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: var(--space-lg) auto;
    max-width: 100%;
}

.ad-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
    font-weight: 500;
}

.ad-placeholder {
    background: transparent;
    border: 1px dashed rgba(113, 113, 122, 0.3);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.55rem;
    overflow: hidden;
}

.ad-banner .ad-placeholder {
    width: 100%;
    max-width: 728px;
    height: 50px;
}

.ad-placeholder::before {
    content: 'Anuncio';
    opacity: 0.5;
}

.ad-rectangle .ad-placeholder {
    width: 300px;
    height: 250px;
}

.ad-footer .ad-placeholder {
    width: 100%;
    max-width: 728px;
    height: 90px;
}

/* Hide ad containers on small screens for better UX */
@media (max-width: 768px) {

    .ad-banner,
    .ad-footer {
        display: none;
    }

    .ad-rectangle .ad-placeholder {
        width: 100%;
        max-width: 300px;
    }
}

/* ============================================
   TEXT GRADIENT UTILITY
   ============================================ */
.text-gradient {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============================================
   FEATURED BADGE - Popular indicator
   ============================================ */
.featured-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.125rem 0.375rem;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.5rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    z-index: 1;
}

/* ============================================
   IDENTITY ANIMATION - Memorable touch
   ============================================ */
@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-6px);
    }
}

.featured-card-icon {
    animation: float 4s ease-in-out infinite;
}

.featured-card:nth-child(2) .featured-card-icon {
    animation-delay: 0.5s;
}

.featured-card:nth-child(3) .featured-card-icon {
    animation-delay: 1s;
}

/* Subtle shimmer on hero title */
@keyframes shimmer {
    0% {
        background-position: -200% center;
    }

    100% {
        background-position: 200% center;
    }
}

.hero-title .text-gradient {
    background: linear-gradient(90deg,
            #6366f1 0%,
            #a78bfa 25%,
            #8b5cf6 50%,
            #a78bfa 75%,
            #6366f1 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    animation: shimmer 3s linear infinite;
}

/* ============================================
   SIDEBAR COLLAPSED - Icon only with tooltips
   ============================================ */
.sidebar-collapsed .sidebar {
    width: 72px;
}

.sidebar-collapsed .sidebar-logo-text,
.sidebar-collapsed .sidebar-section-title,
.sidebar-collapsed .sidebar-link-text,
.sidebar-collapsed .sidebar-toggle,
.sidebar-collapsed .sidebar-ads {
    display: none;
}

.sidebar-collapsed .sidebar-header {
    justify-content: center;
    padding: 0 var(--space-sm);
}

.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding: 0.875rem;
    position: relative;
}

/* Tooltip on hover */
.sidebar-collapsed .sidebar-link::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    padding: 0.5rem 0.75rem;
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.15s ease;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    pointer-events: none;
}

.sidebar-collapsed .sidebar-link:hover::after {
    opacity: 1;
    visibility: visible;
    left: calc(100% + 12px);
}

/* Active indicator - bar on left */
.sidebar-collapsed .sidebar-link.active {
    background: var(--color-primary-soft);
}

.sidebar-collapsed .sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 24px;
    background: var(--color-primary);
    border-radius: 0 4px 4px 0;
}

.sidebar-collapsed .app-content {
    margin-left: 72px;
    width: calc(100% - 72px);
}