/* =========================================
   1. VARIABLES & THEME SETUP
   ========================================= */

@import url('https://fonts.googleapis.com/css2?family=Lato:wght@300;400;600;700&display=swap');

/* Default (Light) Theme */
:root {
    /* Colors */
    --primary: #5a67ff;
    --primary-dark: #4854d9;
    --secondary: #f59e0b;
    --accent: #ec4899;

    /* Backgrounds */
    --background: #F7F7F7;
    --surface: #f8fafc;
    --card: #ffffff;
    --header-bg: #10b981;

    /* Text */
    --text: #1e293b;
    --text-muted: #64748b;
    --text-light: #ffffff;

    /* Borders & Shadows */
    --border: #e2e8f0;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-hero: linear-gradient(135deg, #5a67ff 0%, #c471ed 50%, #f7797d 100%);
}

/* Dark Theme Overlay - Redundant Selectors for Safety */
:root[data-theme="dark"],
html[data-theme="dark"],
html.dark,
body.dark {
    /* Browser UI */
    color-scheme: dark;

    /* Colors */
    --primary: #6b77ff;
    --primary-dark: #5a67ff;

    /* Backgrounds */
    --background: #0f172a;
    --surface: #1e293b;
    --card: #1e293b;
    --header-bg: #059669;

    /* Text */
    --text: #f1f5f9;
    --text-muted: #94a3b8;

    /* Borders & Shadows */
    --border: #334155;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

/* Force overrides specifically for dark mode */
html.dark body,
body.dark {
    background-color: #0f172a !important;
    color: #f1f5f9 !important;
}

html.dark header,
body.dark header {
    background-color: #1e293b !important;
    border-bottom-color: #334155 !important;
}

html.dark .card,
body.dark .card,
html.dark .comic-card,
body.dark .comic-card,
html.dark .dropdown-menu,
body.dark .dropdown-menu {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #f1f5f9 !important;
}

/* Force body background transition */
body {
    background-color: var(--background) !important;
    color: var(--text) !important;
    transition: background-color 0.3s ease, color 0.3s ease;
}

header {
    background-color: var(--header-bg) !important;
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
    transition: background 0.3s, color 0.3s;
}

header {
    background-color: var(--header-bg);
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
    transition: background 0.3s, color 0.3s;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    line-height: 1.2;
}

a {
    text-decoration: none;
    color: inherit;
}

img {
    max-width: 100%;
    height: auto;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* White content sections */
section.container {
    background: var(--card);
    padding: 2rem 1rem;
    margin-bottom: 0;
}

section.container:not(:last-child) {
    margin-bottom: 0;
}

/* Page with sidebar layout */
.page-with-sidebar {
    background: var(--card);
    padding: 2rem 1rem;
}

/* Header */
header {
    background: var(--header-bg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
}

nav ul {
    list-style: none;
    display: flex;
    gap: 2rem;
    align-items: center;
}

nav a {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    transition: color 0.2s;
}

nav a:hover {
    color: white;
}

/* Theme Toggle */
.theme-toggle {
    position: relative;
    width: 50px;
    height: 26px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 13px;
    border: none;
    cursor: pointer;
    transition: background 0.3s;
    padding: 0;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
}

.theme-toggle::before {
    content: '☀️';
    position: absolute;
    left: 3px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

html.dark .theme-toggle::before,
body.dark .theme-toggle::before {
    content: '🌙';
    left: 27px;
    background: #1e293b;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    border: 1px solid transparent;
    font-size: 0.875rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--surface);
}

/* Cards */
.card {
    background: var(--card);
    border-radius: 0;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: all 0.3s;
}

/* Removed hover effect on card to be cleaner as requested */
/* .card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
} */

/* Grid */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.grid-5 {
    grid-template-columns: repeat(5, 1fr);
}

.grid-6 {
    grid-template-columns: repeat(6, 1fr);
}

@media (max-width: 1024px) {
    .grid-6 {
        grid-template-columns: repeat(4, 1fr);
    }

    .grid-5 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {

    .grid-6,
    .grid-5,
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Comic Card */
.comic-card {
    position: relative;
    overflow: hidden;
    border-radius: 0;
    /* Square corners */
    background: var(--card);
    border: none;
    transition: all 0.3s;
}

/* Removed hover effects as requested */
/* .comic-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
} */

.comic-cover {
    aspect-ratio: 2/3;
    overflow: hidden;
    position: relative;
}

.comic-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s;
}

/* Removed image zoom on hover */
/* .comic-card:hover .comic-cover img {
    transform: scale(1.1);
} */

.comic-info {
    padding: 0.5rem 0;
}

.comic-title {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s;
}

.comic-card:hover .comic-title {
    color: var(--primary);
}

/* Type Badge */
.type-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border-radius: 4px;
    font-size: 1.2rem;
    z-index: 10;
    line-height: 1;
}

.type-badge-img {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 24px !important;
    /* Force width override */
    height: auto !important;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    border-radius: 2px;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--surface);
    color: var(--text);
}

.badge-primary {
    background: var(--primary);
    color: white;
}

/* Hero Section */
.hero {
    padding: 4rem 0;
    background: linear-gradient(135deg, rgba(90, 103, 255, 0.1) 0%, rgba(236, 72, 153, 0.1) 100%);
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at top, rgba(90, 103, 255, 0.15), transparent 50%);
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 1;
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.hero p {
    font-size: 1.25rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* Hero with Background Image */
.hero-with-bg {
    padding: 6rem 0;
    background: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)), url('../images/hero-bg.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    position: relative;
    overflow: hidden;
}

.hero-with-bg .hero-content {
    position: relative;
    z-index: 1;
}

.hero-with-bg h1,
.hero-with-bg p {
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Form */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--background);
    color: var(--text);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(90, 103, 255, 0.1);
}

textarea.form-input {
    resize: vertical;
    min-height: 100px;
}

/* Utilities */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
}

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mt-4 {
    margin-top: 2rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mb-4 {
    margin-bottom: 2rem;
}

.p-4 {
    padding: 2rem;
}

/* Loading */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--card);
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    border-left: 4px solid #10b981;
}

.toast.error {
    border-left: 4px solid #ef4444;
}

/* Dark mode toggle */
.theme-toggle {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.theme-toggle:hover {
    background: var(--primary);
    color: white;
}

/* Responsive */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 2rem;
    }

    nav ul {
        gap: 1rem;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
}

/* Dropdown Menu */
.dropdown {
    position: relative;
}

.dropdown-toggle {
    cursor: pointer;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    z-index: 1000;
    margin-top: 0.5rem;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-menu a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text);
    transition: background 0.2s;
}

.dropdown-menu a:hover {
    background: var(--surface);
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 0.5rem 0;
}

/* Avatar */
.avatar-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.125rem;
}

.user-info {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.user-email {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Hero with Background */
.hero-with-bg {
    position: relative;
    padding: 6rem 0;
    background-image: url('https://images.unsplash.com/photo-1612036782180-6f0b6cd846fe?w=1920&q=80');
    background-size: cover;
    background-position: center;
    overflow: hidden;
}

.hero-with-bg::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(90, 103, 255, 0.9) 0%, rgba(236, 72, 153, 0.8) 100%);
}

.hero-with-bg .hero-content {
    position: relative;
    z-index: 1;
}

.hero-with-bg h1,
.hero-with-bg p {
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Sidebar */
.page-with-sidebar {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.sidebar {
    background: var(--card);
    border-radius: 1rem;
    padding: 1.5rem;
    border: 1px solid var(--border);
    height: fit-content;
    position: sticky;
    top: 80px;
}

.sidebar h3 {
    margin-bottom: 1rem;
    font-size: 1.125rem;
}

.filter-group {
    margin-bottom: 1.5rem;
}

.filter-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 0.375rem;
    transition: background 0.2s;
}

.filter-group label:hover {
    background: var(--surface);
}

.filter-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    background: var(--card);
    color: var(--text);
    text-decoration: none;
    transition: all 0.2s;
    min-width: 40px;
    text-align: center;
}

.pagination a:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.pagination .active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.pagination .disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Search Box */
.search-box {
    margin-bottom: 1.5rem;
}

.search-box input {
    width: 100%;
    max-width: 400px;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--background);
    color: var(--text);
    font-size: 1rem;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(90, 103, 255, 0.1);
}

@media (max-width: 1024px) {
    .page-with-sidebar {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
    }
}