@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Geist:wght@300;400;500;600;700&display=swap');

:root {
    --font-display: 'Plus Jakarta Sans', sans-serif;
    --font-body: 'Geist', sans-serif;

    --bg: #0f0f0f;
    --surface: #1a1a1a;
    --elevated: #252525;
    --hover-surface: #333333;
    --border: #2a2a2a;

    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --text-muted: #666666;

    --accent: #0dc5e5;
    --accent-hover: #0da8e5;
    --accent-soft: rgba(229, 160, 13, 0.12);

    --danger: #ef4444;
    --warning: #f59e0b;

    --sidebar-width: 240px;
    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 12px;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.25);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.35), 0 2px 4px -2px rgb(0 0 0 / 0.25);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.45), 0 4px 6px -4px rgb(0 0 0 / 0.35);
    --shadow-glow: 0 0 20px -5px rgba(229, 160, 13, 0.25);

    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg: #f5f5f5;
    --surface: #ffffff;
    --elevated: #f0f0f0;
    --hover-surface: #e5e5e5;
    --border: #e0e0e0;

    --text-primary: #111111;
    --text-secondary: #555555;
    --text-muted: #888888;

    --accent-soft: rgba(229, 160, 13, 0.10);

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.06);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.06);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.10), 0 4px 6px -4px rgb(0 0 0 / 0.08);
    --shadow-glow: 0 0 20px -5px rgba(229, 160, 13, 0.20);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: var(--transition);
}

body > .container {
    display: flex;
    height: 100vh;
}

/* Loading */
#loading {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 15, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 100000;
    pointer-events: all;
}

[data-theme="light"] #loading {
    background: rgba(245, 245, 245, 0.8);
}

#loading > p {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 15px;
    font-weight: 500;
    font-family: var(--font-body);
    background-color: var(--surface);
    color: var(--text-primary);
    padding: 24px 36px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 100001;
    border: 1px solid var(--border);
    animation: loadingPulse 1.5s ease-in-out infinite;
}

@keyframes loadingPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

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

.spin { animation: spin 1s linear infinite; }

/* Search & Empty States */
body > .container .search {
    text-align: center;
    margin-top: 30vh;
    font-size: 18px;
    transition: var(--transition);
}

body > .container .search input,
body > .container .search button {
    font-size: 16px;
    font-family: var(--font-body);
}

body > .container .no-data {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    font-weight: 500;
    color: var(--text-muted);
    padding: 32px 48px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--border);
    z-index: 9999;
}

/* Side Menu */
body > .container > .side-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    padding: 24px 16px;
    background-color: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 999;
    transition: transform 0.3s ease;
}

/* Hamburger */
.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    flex-direction: column;
    gap: 5px;
    z-index: 1001;
}
.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-color, #e0e0e0);
    border-radius: 1px;
    transition: transform 0.3s, opacity 0.3s;
}
.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}
.hamburger.active span:nth-child(2) {
    opacity: 0;
}
.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}
.side-menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
}
.side-menu-overlay.active {
    display: block;
}

.side-menu .brand {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 36px;
    padding-left: 8px;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.side-menu .brand-icon {
    width: 32px;
    height: 32px;
    color: var(--accent);
    flex-shrink: 0;
}

.side-menu .nav-list {
    list-style: none;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.side-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    position: relative;
}

.side-menu a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 3px;
    height: 18px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
    transition: transform 0.2s ease;
}

.side-menu a:hover,
.side-menu a.active {
    color: var(--accent);
    background: var(--accent-soft);
}

.side-menu a:hover::before,
.side-menu a.active::before {
    transform: translateY(-50%) scaleY(1);
}

.side-menu a svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.9;
}

/* Theme icon visibility */
[data-theme="dark"] .icon-light { display: none; }
[data-theme="light"] .icon-dark { display: none; }

/* Content Area */
body > .container > .content {
    margin-left: var(--sidebar-width);
    width: calc(100vw - var(--sidebar-width));
    height: 100vh;
    overflow-y: auto;
    background-color: var(--bg);
    transition: var(--transition);
}

/* Topbar / Header View */
.topbar,
.header-view {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(15, 15, 15, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 16px 32px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    transition: var(--transition);
}

[data-theme="light"] .topbar,
[data-theme="light"] .header-view {
    background: rgba(245, 245, 245, 0.7);
}

.topbar.scrolled,
.header-view.scrolled {
    box-shadow: var(--shadow-sm);
}

/* ── Header User Component ── */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.header-user {
    position: relative;
    flex-shrink: 0;
    margin-left: auto;
}
.header-user-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1.5px solid var(--border);
    transition: border-color 0.2s, box-shadow 0.2s;
    text-decoration: none;
}
.header-user-btn:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(229,160,13,0.12);
}
.header-user-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.header-user-initial {
    width: 100%;
    height: 100%;
    background: var(--accent);
    color: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
}
.header-user-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 100;
    overflow: hidden;
    padding-top: 8px;
    animation: dropdownFadeIn 0.15s ease;
}
@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}
.header-user:hover .header-user-dropdown,
.header-user.open .header-user-dropdown {
    display: block;
}
.header-user-dropdown-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}
.header-user-dropdown-name {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.header-user-dropdown-role {
    font-size: 11px;
    color: var(--accent);
    text-transform: capitalize;
    font-weight: 500;
}
.header-user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}
.header-user-dropdown-item:hover {
    background: rgba(229,160,13,0.06);
    color: var(--text-primary);
}
.header-user-dropdown-item svg {
    flex-shrink: 0;
    opacity: 0.6;
}
.header-user-dropdown-item:hover svg {
    opacity: 1;
}
.header-user-dropdown-logout {
    border-top: 1px solid var(--border);
    margin: 0;
    padding: 0;
}
.header-user-dropdown-logout button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    font-size: 13px;
    color: #ef4444;
    cursor: pointer;
    transition: background 0.15s;
    font-family: inherit;
    text-align: left;
}
.header-user-dropdown-logout:hover button {
    background: rgba(239,68,68,0.08);
}
.header-user-login {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--border);
    color: var(--text-muted);
    transition: border-color 0.2s, color 0.2s;
    flex-shrink: 0;
    text-decoration: none;
}
.header-user-login:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.page-title {
    font-size: 22px;
    margin: 0;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--text-primary);
}

p {
    color: var(--text-secondary);
    line-height: 1.7;
}

/* Buttons */
button,
.btn,
.primary {
    padding: 10px 18px;
    color: #0f0f0f;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
    text-decoration: none;
}

button::after,
.btn::after,
.primary::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0) 100%);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

button:hover,
.btn:hover,
.primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

button:hover::after,
.btn:hover::after,
.primary:hover::after {
    opacity: 1;
}

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

button.secondary,
.btn.secondary,
.secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

[data-theme="light"] button.secondary,
[data-theme="light"] .btn.secondary,
[data-theme="light"] .secondary {
    border-color: rgba(0, 0, 0, 0.15);
    color: var(--text-primary);
}

button.secondary:hover,
.btn.secondary:hover,
.secondary:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: none;
}

/* Inputs */
input[type="text"],
input[type="search"],
input[type="number"],
input[type="password"],
input[type="email"],
select,
textarea {
    font-family: var(--font-body);
    font-size: 14px;
    padding: 10px 14px;
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: var(--transition);
    width: 100%;
}

input[type="text"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

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

/* Search Bar */
.search-bar {
    display: flex;
    gap: 10px;
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px;
}

.search-bar input {
    flex: 1;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.badge-accent {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent);
}

.badge-muted {
    background: var(--elevated);
    color: var(--text-muted);
    border-color: var(--border);
}

/* Genre Tags */
.genre-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.genre-tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--accent);
    cursor: default;
    transition: var(--transition);
}

.genre-tag:hover {
    background: var(--accent);
    color: #0f0f0f;
}

[data-theme="light"] .genre-tag:hover {
    color: #111111;
}

/* Anime List / Items */
.anime-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    padding: 16px 32px;
}

.anime-item {
    background: var(--surface);
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    transition: var(--transition);
    cursor: pointer;
}

.anime-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
    border-color: var(--hover-surface);
}

.anime-item img {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 2/3;
    object-fit: cover;
}

.anime-item .info {
    padding: 10px 12px;
}

.anime-item .title {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.anime-item .meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.anime-item-media {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--elevated);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.anime-item-media:hover {
    background: var(--hover-surface);
}

/* Provider Tabs */
.provider-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    padding: 0 32px;
}

.provider-tab {
    padding: 6px 16px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.provider-tab:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.provider-tab.active {
    background: var(--accent);
    color: #0f0f0f;
    border-color: var(--accent);
}

.provider-badge {
    background: var(--elevated);
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    margin-left: 8px;
    border: 1px solid var(--border);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: #ccc;
}

::-webkit-scrollbar-thumb:hover {
    background: #444;
}

[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* Selection */
::selection {
    background: var(--accent);
    color: #0f0f0f;
}

/* Responsive */
@media (max-width: 768px) {
    body > .container > .side-menu {
        width: 100%;
        transform: translateX(-100%);
    }

    body > .container > .side-menu.open {
        transform: translateX(0) !important;
    }

    .hamburger {
        display: flex;
    }

    body > .container > .content {
        margin-left: 0;
        width: 100vw;
    }

    .topbar,
    .header-view {
        padding: 14px 20px;
    }

    .anime-list {
        padding: 14px 20px;
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .provider-tabs {
        padding: 0 20px;
    }

    .toast-container {
        right: 12px;
        bottom: 12px;
    }

    .toast {
        min-width: 260px;
        max-width: 340px;
        padding: 12px 16px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .admin-container,
    .profile-container {
        padding: 16px !important;
        max-width: 100% !important;
    }
    .topbar {
        padding: 8px 12px !important;
    }
    .content {
        padding: 12px !important;
    }
    .anime-list {
        padding: 8px !important;
    }
    .header-user-dropdown {
        right: -8px;
        min-width: 180px;
    }
    .header-view {
        padding: 8px 12px !important;
    }
}

/* ================================================
   Page Transition
   ================================================ */

@keyframes pageIn {
    0% {
        opacity: 0;
        transform: translateY(8px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

body > .container > .content {
    animation: pageIn 0.35s ease-out both;
}

/* ================================================
   Toast Notifications
   ================================================ */

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    z-index: 10000;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    min-width: 320px;
    max-width: 420px;
    padding: 14px 20px;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    background: rgba(26, 26, 26, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toastSlideIn 0.35s ease-out both, toastFadeOut 0.3s ease-in 2.7s both;
    overflow: hidden;
    position: relative;
}

.toast::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    border-radius: 3px 0 0 3px;
}

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

.toast-message {
    flex: 1;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 16px;
    line-height: 1;
    transition: var(--transition);
    flex-shrink: 0;
}

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

/* Toast variants */
.toast-success {
    border-left-color: #10b981;
}

.toast-success::before {
    background: #10b981;
}

.toast-success .toast-icon {
    color: #10b981;
}

.toast-error {
    border-left-color: #ef4444;
}

.toast-error::before {
    background: #ef4444;
}

.toast-error .toast-icon {
    color: #ef4444;
}

.toast-info {
    border-left-color: #3b82f6;
}

.toast-info::before {
    background: #3b82f6;
}

.toast-info .toast-icon {
    color: #3b82f6;
}

/* Light theme toast background */
[data-theme="light"] .toast {
    background: rgba(255, 255, 255, 0.85);
}

@keyframes toastSlideIn {
    0% {
        opacity: 0;
        transform: translateX(100%);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastFadeOut {
    0% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translateX(40px);
    }
}
