/* ============================
   DESIGN SYSTEM
   ============================ */
:root {
    /* Colors */
    --bg-primary: #0a0b10;
    --bg-secondary: #12141d;
    --bg-card: #181b27;
    --bg-card-hover: #1e2233;
    --bg-input: #1a1d2a;
    --bg-modal: #14161f;

    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-default: rgba(255, 255, 255, 0.1);
    --border-hover: rgba(255, 255, 255, 0.15);

    --text-primary: #e8eaf0;
    --text-secondary: #9198ac;
    --text-tertiary: #5d6478;
    --text-inverse: #0a0b10;

    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
    --accent-glow: rgba(99, 102, 241, 0.15);

    --success: #34d399;
    --error: #f87171;
    --warning: #fbbf24;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-xs: 0.75rem;
    --font-sm: 0.8125rem;
    --font-md: 0.9375rem;
    --font-lg: 1.125rem;
    --font-xl: 1.5rem;
    --font-2xl: 2rem;

    /* Borders */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 24px rgba(99, 102, 241, 0.2);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-default: 250ms ease;
    --transition-slow: 400ms ease;
}

/* ============================
   RESET & BASE
   ============================ */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ============================
   LOGIN SCREEN
   ============================ */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--space-lg);
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

.login-screen::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 30% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 50%, rgba(139, 92, 246, 0.05) 0%, transparent 60%);
    animation: loginBgPulse 8s ease-in-out infinite alternate;
}

@keyframes loginBgPulse {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(-2%, -1%) scale(1.05);
    }
}

.login-card {
    position: relative;
    text-align: center;
    padding: var(--space-2xl) var(--space-xl);
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 380px;
    animation: fadeInUp 0.6s ease;
}

.login-logo {
    margin-bottom: var(--space-lg);
}

.login-title {
    font-size: var(--font-xl);
    font-weight: 700;
    margin-bottom: var(--space-xs);
    letter-spacing: -0.02em;
}

.login-subtitle {
    font-size: var(--font-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-xl);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.input-group {
    display: flex;
    gap: var(--space-sm);
}

.input-group input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: var(--font-md);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-group input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.btn-login {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    flex-shrink: 0;
}

.btn-login:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

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

/* Bouton « Se connecter avec mon compte NeOrigin » (pleine largeur) */
.btn-login.btn-login-large {
    width: 100%;
    height: auto;
    padding: 14px 20px;
    font: inherit;
    font-weight: 600;
}

.login-error {
    font-size: var(--font-sm);
    color: var(--error);
    animation: shake 0.4s ease;
}

@keyframes shake {

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

    25% {
        transform: translateX(-6px);
    }

    75% {
        transform: translateX(6px);
    }
}

/* ============================
   APP LAYOUT
   ============================ */
.app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
    padding-bottom: var(--space-3xl);
}

/* ============================
   HEADER
   ============================ */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg) 0;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: var(--space-lg);
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.header-title {
    font-size: var(--font-lg);
    font-weight: 600;
    letter-spacing: -0.02em;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.btn-add {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 10px 20px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-family: var(--font-family);
    font-size: var(--font-sm);
    font-weight: 500;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.btn-add:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

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

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-icon:hover {
    color: var(--text-primary);
    border-color: var(--border-hover);
    background: var(--bg-card);
}

/* ============================
   NAVIGATION TABS
   ============================ */
.tabs {
    display: flex;
    gap: var(--space-xs);
    padding: var(--space-xs);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-xl);
    border: 1px solid var(--border-subtle);
}

.tab {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: var(--font-sm);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    flex: 1;
    justify-content: center;
}

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

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

/* ============================
   SECTION HEADERS
   ============================ */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
}

.section-header h2 {
    font-size: var(--font-lg);
    font-weight: 600;
    letter-spacing: -0.01em;
}

.link-count {
    font-size: var(--font-sm);
    color: var(--text-tertiary);
    background: var(--bg-secondary);
    padding: 4px 12px;
    border-radius: 999px;
    border: 1px solid var(--border-subtle);
}

/* ============================
   LINKS GRID
   ============================ */
.links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: var(--space-lg);
}

.link-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: transform var(--transition-default), border-color var(--transition-default), box-shadow var(--transition-default);
    animation: fadeInUp 0.4s ease backwards;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

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

.link-card-image {
    width: 100%;
    height: 180px;
    background: var(--bg-secondary);
    background-size: cover;
    background-position: center;
    position: relative;
    overflow: hidden;
}

.link-card-image::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(transparent, var(--bg-card));
}

.link-card-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-card));
}

.link-card-body {
    padding: var(--space-md) var(--space-lg) var(--space-lg);
}

.link-card-domain {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-xs);
    color: var(--accent-primary);
    margin-bottom: var(--space-sm);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.link-card-domain img {
    width: 14px;
    height: 14px;
    border-radius: 3px;
}

.link-card-title {
    font-size: var(--font-md);
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: var(--space-sm);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    letter-spacing: -0.01em;
}

.link-card-desc {
    font-size: var(--font-sm);
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: var(--space-md);
}

.link-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: var(--font-xs);
    color: var(--text-tertiary);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-subtle);
}

.link-card-author {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.author-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    color: white;
    text-transform: uppercase;
}

.link-card-tags {
    display: flex;
    gap: var(--space-xs);
    flex-wrap: wrap;
}

.tag {
    padding: 2px 8px;
    background: var(--accent-glow);
    color: var(--accent-primary);
    border-radius: 999px;
    font-size: 10px;
    font-weight: 500;
}

/* ============================
   EMPTY & LOADING STATES
   ============================ */
.empty-state {
    text-align: center;
    padding: var(--space-3xl) var(--space-lg);
    color: var(--text-tertiary);
}

.empty-state svg {
    margin-bottom: var(--space-lg);
    opacity: 0.4;
}

.empty-state p {
    font-size: var(--font-md);
    margin-bottom: var(--space-lg);
}

.btn-add-secondary {
    padding: 10px 24px;
    background: transparent;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: var(--font-sm);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

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

.loading-state {
    text-align: center;
    padding: var(--space-3xl) var(--space-lg);
    color: var(--text-tertiary);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-default);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    margin: 0 auto var(--space-md);
    animation: spin 0.8s linear infinite;
}

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

/* ============================
   PLAYLIST
   ============================ */
.playlist-layout {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.playlist-player {
    width: 100%;
}

.playlist-embed {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-subtle);
}

.playlist-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.playlist-videos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-md);
    max-height: 600px;
    overflow-y: auto;
    padding-right: var(--space-xs);
}

.playlist-videos::-webkit-scrollbar {
    width: 6px;
}

.playlist-videos::-webkit-scrollbar-track {
    background: transparent;
}

.playlist-videos::-webkit-scrollbar-thumb {
    background: var(--border-default);
    border-radius: 3px;
}

.playlist-videos::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

.playlist-videos-loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-tertiary);
}

.video-item {
    display: flex;
    gap: var(--space-md);
    padding: var(--space-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
    color: inherit;
    animation: fadeInUp 0.3s ease backwards;
}

.video-item:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
}

.video-item.active {
    border-color: var(--accent-primary);
    background: var(--accent-glow);
}

.video-item-thumb {
    width: 120px;
    height: 68px;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.video-item-thumb::after {
    content: '▶';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    color: white;
    font-size: 14px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.video-item:hover .video-item-thumb::after {
    opacity: 1;
}

.video-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.video-item-title {
    font-size: var(--font-sm);
    font-weight: 500;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-item-date {
    font-size: var(--font-xs);
    color: var(--text-tertiary);
}

.video-item-index {
    font-size: var(--font-xs);
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    align-self: center;
}

.playlist-info {
    margin-top: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.playlist-hint {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-sm);
    color: var(--text-tertiary);
    background: var(--bg-secondary);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    width: 100%;
}

/* ============================
   MODAL
   ============================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--space-lg);
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--bg-modal);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.3s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg) var(--space-lg) 0;
}

.modal-header h3 {
    font-size: var(--font-lg);
    font-weight: 600;
}

.btn-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

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

/* ============================
   FORM
   ============================ */
.add-link-form {
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

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

.form-group .optional {
    font-weight: 400;
    color: var(--text-tertiary);
}

.form-group input {
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: var(--font-md);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-group input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.form-error {
    font-size: var(--font-sm);
    color: var(--error);
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.2);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
}

.form-preview {
    display: flex;
    gap: var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    animation: fadeIn 0.3s ease;
}

.preview-image {
    width: 80px;
    height: 60px;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
}

.preview-info {
    flex: 1;
    min-width: 0;
}

.preview-title {
    font-size: var(--font-sm);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.preview-desc {
    font-size: var(--font-xs);
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.btn-submit {
    padding: 14px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-family: var(--font-family);
    font-size: var(--font-md);
    font-weight: 600;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    position: relative;
    margin-top: var(--space-sm);
}

.btn-submit:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

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

.btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

/* ============================
   ANIMATIONS
   ============================ */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================
   RESPONSIVE
   ============================ */
@media (max-width: 768px) {
    .app {
        padding: 0 var(--space-md);
        padding-bottom: var(--space-2xl);
    }

    .header {
        flex-direction: column;
        gap: var(--space-md);
        align-items: flex-start;
    }

    .header-right {
        width: 100%;
    }

    .btn-add {
        flex: 1;
        justify-content: center;
    }

    .links-grid {
        grid-template-columns: 1fr;
    }

    .tabs {
        flex-direction: column;
    }

    .btn-add span {
        display: inline;
    }

    .modal {
        margin: var(--space-md);
    }
}

@media (max-width: 480px) {
    .link-card-image {
        height: 140px;
    }
}