/* =========================================
   1. LAYOUT & ESTRUCTURA BASE
   ========================================= */
.main-wrapper {
    width: 100%;
    min-height: 100vh;
    padding-bottom: 6rem;
    position: relative;
    overflow-x: hidden;
}

/* Efecto de fondo ambiental (Glow superior) */
.main-wrapper::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 60vh;
    background: radial-gradient(circle at 50% 0%, rgba(139, 92, 246, 0.15), transparent 70%);
    z-index: -1;
    pointer-events: none;
}

.content-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 3rem;
    animation: fadeInUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

/* =========================================
   2. PERFIL (Modern Header)
   ========================================= */
.profile-header {
    background: var(--color-bg-elevated, #18181b);
    border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.05));
    padding-bottom: 0;
    margin-bottom: 2rem;
    position: relative;
}

.profile-banner {
    height: 200px;
    background: linear-gradient(120deg, #2e1065, #8b5cf6);
    width: 100%;
    position: relative;
}

.profile-body {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 3rem;
    display: flex;
    align-items: flex-end;
    gap: 2rem;
    margin-top: -60px; /* Superposición sobre el banner */
    position: relative;
    z-index: 2;
}

/* Avatar */
.profile-avatar-wrapper {
    position: relative;
    width: 160px;
    height: 160px;
    flex-shrink: 0;
}

.avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 5px solid var(--color-bg-base, #09090b);
    object-fit: cover;
    background: var(--color-bg-elevated, #18181b);
}

.avatar-edit-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    opacity: 0;
    cursor: pointer;
    transition: 0.2s;
    border: 5px solid transparent;
}

.profile-avatar-wrapper:hover .avatar-edit-overlay {
    opacity: 1;
}

/* Detalles de Texto y Badges */
.profile-details {
    flex-grow: 1;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.username-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.profile-text h1 {
    font-size: 2.5rem;
    margin: 0;
    line-height: 1.2;
}

.header-anilist-badge {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
}

.header-anilist-badge img { width: 100%; height: 100%; object-fit: cover; }
.header-anilist-badge:hover { transform: scale(1.1); box-shadow: 0 0 15px rgba(61, 180, 242, 0.5); }

/* Estadísticas */
.profile-stats-grid { display: flex; gap: 1.5rem; }

.stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255,255,255,0.03);
    padding: 0.5rem 1.5rem;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.05);
}

.stat-value { font-size: 1.4rem; font-weight: 800; color: white; }
.stat-label { font-size: 0.8rem; color: var(--color-text-secondary, #a1a1aa); text-transform: uppercase; letter-spacing: 0.5px; }

/* Responsive Profile */
@media (max-width: 900px) {
    .profile-body { flex-direction: column; align-items: center; margin-top: -100px; text-align: center; }
    .profile-details { flex-direction: column; align-items: center; width: 100%; }
    .profile-stats-grid { justify-content: center; width: 100%; }
    .username-wrapper { justify-content: center; }
}

/* =========================================
   3. NAVEGACIÓN (Pills Modernos)
   ========================================= */
.hub-navigation-modern {
    display: flex;
    gap: 1rem;
    max-width: 1400px;
    margin: 1rem auto 0 auto;
    padding: 0 3rem 1rem 3rem;
}

.nav-pill {
    background: transparent;
    border: none;
    color: var(--color-text-secondary, #a1a1aa);
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.2s;
}

.nav-pill:hover { background: rgba(255,255,255,0.05); color: white; }
.nav-pill.active { background: var(--color-primary, #8b5cf6); color: white; }

@media (max-width: 768px) {
    .hub-navigation-modern { justify-content: center; padding-left: 1rem; padding-right: 1rem; flex-wrap: wrap; }
}

.tab-section {
    display: none;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s, transform 0.3s;
}

.tab-section.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* =========================================
   4. TOOLBAR & CONTROLES
   ========================================= */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.05);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    backdrop-filter: blur(5px);
    flex-wrap: wrap;
    gap: 1rem;
}

/* Local Toolbar Variant */
.toolbar.local-toolbar {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 1.5rem;
}

.search-box {
    position: relative;
    flex-grow: 1;
    max-width: 400px;
}

.search-box svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted, #71717a);
    pointer-events: none;
}

.search-input {
    width: 100%;
    background: rgba(0,0,0,0.2);
    border: 1px solid transparent;
    padding: 0.7rem 1rem 0.7rem 2.8rem;
    border-radius: 8px;
    color: white;
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.search-input:focus {
    background: rgba(0,0,0,0.4);
    border-color: var(--color-primary, #8b5cf6);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.filters-inline {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    flex-wrap: wrap;
}

.minimal-select {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--color-text-secondary, #a1a1aa);
    padding: 0.6rem 2rem 0.6rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    transition: 0.2s;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23a1a1aa'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    background-size: 1rem;
}

.minimal-select:hover { background: rgba(255,255,255,0.1); color: white; }
.minimal-select:focus { border-color: var(--color-primary, #8b5cf6); color: white; }

.view-toggle {
    display: flex;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    padding: 2px;
}

.view-btn {
    background: transparent;
    border: none;
    color: var(--color-text-muted, #71717a);
    padding: 0.5rem 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
}

.view-btn.active, .view-btn:hover { background: rgba(255,255,255,0.1); color: white; }

/* Switcher Local (Segmented Control) */
.local-type-switcher {
    display: flex;
    background: rgba(0,0,0,0.3);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.05);
}

.type-pill-btn {
    background: transparent;
    border: none;
    color: var(--color-text-secondary, #a1a1aa);
    padding: 0.5rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.type-pill-btn:hover { color: white; }
.type-pill-btn.active {
    background: var(--color-bg-elevated, #18181b);
    color: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Action Buttons (Scan) */
.actions-group {
    display: flex;
    gap: 0.5rem;
    border-left: 1px solid rgba(255,255,255,0.1);
    padding-left: 1.5rem;
}

.action-icon-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--color-text-secondary, #a1a1aa);
    width: 40px; height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
}

.action-icon-btn:hover { background: var(--color-primary, #8b5cf6); border-color: var(--color-primary, #8b5cf6); color: white; }
.action-icon-btn.danger:hover { background: rgba(239, 68, 68, 0.2); border-color: #ef4444; color: #ef4444; }

@media (max-width: 768px) {
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar.local-toolbar { grid-template-columns: 1fr; gap: 1rem; }
    .actions-group { border-left: none; padding-left: 0; justify-content: flex-end; }
    .local-type-switcher, .type-pill-btn { width: 100%; flex: 1; }
    .search-box { max-width: 100%; }
    .filters-inline { justify-content: space-between; }
    .minimal-select { flex: 1; }
}

/* =========================================
   5. LIST GRID (Cards)
   ========================================= */
.list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 2rem 1.5rem;
}

.list-item {
    position: relative;
    border-radius: 8px;
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.3s;
    cursor: pointer;
}

.list-item:hover { transform: scale(1.05); z-index: 10; }

.item-poster-link {
    display: block;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 2/3;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.item-poster {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: filter 0.3s;
}

.list-item:hover .item-poster { filter: brightness(1.1); }

.item-content { padding-top: 0.8rem; }

.item-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0 0 0.4rem 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: rgba(255,255,255,0.9);
}

.list-item:hover .item-title { color: var(--color-primary, #8b5cf6); }

.item-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.meta-pill {
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-pill { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.type-pill { background: rgba(255, 255, 255, 0.1); color: #e4e4e7; }
.source-pill { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.repeat-pill { background: rgba(234, 179, 8, 0.15); color: #facc15; }
.private-pill { background: rgba(239, 68, 68, 0.15); color: #f87171; }

.progress-bar-container {
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    margin-bottom: 0.4rem;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--color-primary, #8b5cf6);
    border-radius: 2px;
}

.progress-text {
    font-size: 0.8rem;
    color: var(--color-text-secondary, #a1a1aa);
    display: flex;
    justify-content: space-between;
}

/* Edit Button (Hover) */
.edit-icon-btn {
    position: absolute;
    top: 10px; right: 10px;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(-5px);
    transition: all 0.2s;
    z-index: 20;
    cursor: pointer;
}

.list-item:hover .edit-icon-btn { opacity: 1; transform: translateY(0); }
.edit-icon-btn:hover { background: var(--color-primary, #8b5cf6); border-color: var(--color-primary, #8b5cf6); }

/* Badges adicionales */
.unmatched-badge {
    position: absolute;
    top: 10px; left: 10px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fbbf24;
    display: flex; align-items: center; gap: 4px;
}

.folder-path-tooltip {
    font-size: 0.75rem;
    color: var(--color-text-muted, #71717a);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 0.2rem;
}

/* --- LIST VIEW MODE --- */
.list-grid.list-view { grid-template-columns: 1fr; gap: 1rem; }

.list-grid.list-view .list-item {
    display: flex;
    align-items: center;
    background: var(--color-bg-elevated, #18181b);
    padding: 1rem;
    border: 1px solid rgba(255,255,255,0.05);
}

.list-grid.list-view .list-item:hover {
    transform: scale(1.01);
    border-color: var(--color-primary, #8b5cf6);
}

.list-grid.list-view .item-poster-link { width: 60px; aspect-ratio: 2/3; margin-right: 1.5rem; flex-shrink: 0; }
.list-grid.list-view .item-content { padding-top: 0; flex-grow: 1; display: flex; align-items: center; justify-content: space-between; }
.list-grid.list-view .item-title { font-size: 1.1rem; margin-bottom: 0.2rem; }
.list-grid.list-view .edit-icon-btn { position: static; opacity: 1; transform: none; background: transparent; border: 1px solid rgba(255,255,255,0.1); }

/* =========================================
   6. CONFIGURACIÓN (Stream Style)
   ========================================= */
.stream-settings-container {
    max-width: 800px;
    margin: 0 auto;
    padding-top: 1rem;
    color: #e5e5e5;
}

.stream-section {
    margin-bottom: 2.5rem;
    padding-bottom: 2.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.stream-section.no-border { border-bottom: none; }

.section-label {
    font-size: 1.1rem;
    color: #a1a1aa;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1.5rem;
    font-weight: 600;
}

/* Row de Perfil */
.stream-profile-row { display: flex; gap: 3rem; align-items: flex-start; }

.stream-avatar-wrapper {
    position: relative;
    width: 120px; height: 120px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: #27272a;
}

.stream-avatar-wrapper img { width: 100%; height: 100%; object-fit: cover; }

.avatar-overlay {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; cursor: pointer; transition: 0.2s;
    font-weight: 600; text-transform: uppercase; font-size: 0.8rem;
}

.stream-avatar-wrapper:hover .avatar-overlay { opacity: 1; }

.stream-inputs-col { flex-grow: 1; display: flex; flex-direction: column; gap: 1.5rem; }

/* Formularios */
.stream-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: end; }

.stream-input-group { display: flex; flex-direction: column; gap: 0.5rem; }
.stream-input-group label { font-size: 0.85rem; color: #d4d4d8; font-weight: 500; }

.stream-input {
    background: #27272a;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 0.8rem 1rem;
    color: white;
    font-size: 1rem;
    transition: 0.2s;
}

.stream-input:focus { background: #3f3f46; outline: none; border-color: var(--color-primary, #8b5cf6); }

/* Botones Settings */
.stream-actions { margin-top: 0.5rem; }

.btn-stream-primary {
    background: white; color: black;
    border: none; padding: 0.7rem 2rem;
    font-weight: 700; border-radius: 4px;
    cursor: pointer; transition: 0.2s;
}
.btn-stream-primary:hover { background: #d4d4d8; }

.btn-stream-ghost {
    background: transparent; border: 1px solid #52525b;
    color: white; padding: 0.75rem 1.5rem;
    border-radius: 4px; cursor: pointer;
    font-weight: 600; height: 46px;
}
.btn-stream-ghost:hover { border-color: white; background: rgba(255,255,255,0.05); }

/* Integraciones */
.stream-integration-row {
    display: flex; justify-content: space-between; align-items: center;
    background: rgba(255,255,255,0.03);
    padding: 1rem 1.5rem;
    border-radius: 6px;
}

.int-info { display: flex; align-items: center; gap: 1rem; }
.int-logo { width: 32px; height: 32px; }
.int-text { display: flex; flex-direction: column; }
.int-name { font-weight: 700; font-size: 1rem; }
.int-status { font-size: 0.85rem; color: #a1a1aa; }

.btn-stream-outline {
    background: transparent; border: none;
    color: var(--color-primary, #8b5cf6);
    font-weight: 600; cursor: pointer; font-size: 0.95rem;
}
.btn-stream-outline:hover { text-decoration: underline; }
.btn-danger-outline { color: #ef4444; border: 1px solid #ef4444; padding: 0.5rem 1rem; border-radius: 4px; }

.link-danger {
    background: transparent; border: none;
    color: #ef4444; font-size: 1rem;
    cursor: pointer; padding: 0;
    text-decoration: underline; opacity: 0.8;
}
.link-danger:hover { opacity: 1; }

@media (max-width: 768px) {
    .stream-profile-row { flex-direction: column; align-items: center; text-align: center; gap: 2rem; }
    .stream-form-row { grid-template-columns: 1fr; }
    .btn-stream-ghost { width: 100%; }
    .stream-actions { display: flex; justify-content: center; }
}

/* =========================================
   7. UTILIDADES & ESTADOS (Loading/Console)
   ========================================= */
.loading-state {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; padding: 4rem 0;
    color: var(--color-text-secondary, #a1a1aa);
}

.spinner {
    width: 40px; height: 40px;
    border: 3px solid rgba(139, 92, 246, 0.1);
    border-top-color: var(--color-primary, #8b5cf6);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 1rem;
}
.spinner.small { width: 20px; height: 20px; border-width: 2px; margin-bottom: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
    text-align: center; padding: 5rem 2rem;
    background: rgba(255,255,255,0.02);
    border-radius: 20px;
    border: 2px dashed rgba(255,255,255,0.05);
}
.empty-state p { font-size: 1.2rem; color: var(--color-text-secondary, #a1a1aa); margin-bottom: 1.5rem; }

.btn-blur {
    background: rgba(255,255,255,0.1); backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
    color: white; padding: 0.8rem 1.5rem;
    border-radius: 99px; text-decoration: none;
    display: inline-block; transition: 0.2s;
}
.btn-blur:hover { background: white; color: black; }

.console-output {
    background: #09090b; border: 1px solid #27272a;
    padding: 1.5rem; border-radius: 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem; color: #4ade80;
    display: flex; align-items: center; gap: 1rem;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.5);
    margin-bottom: 1.5rem;
}

.hidden { display: none !important; }