:root {
    /* Primary Color Palette */
    --primary-color: #3a86ff;
    --secondary-color: #ff006e;
    --accent-color: #ffbe0b;
    --success-color: #06ffa5;
    --info-color: #8338ec;
    
    /* Neutrals */
    --white: #ffffff;
    --light-gray: #f8f9fa;
    --medium-gray: #e9ecef;
    --dark-gray: #495057;
    --text-color: #212529;
    --sidebar-bg: #f1f3f5;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 16px rgba(0,0,0,0.15);
    --shadow-xl: 0 12px 24px rgba(0,0,0,0.2);
    
    /* Border Radius */
    --border-radius-sm: 6px;
    --border-radius-md: 12px;
    --border-radius-lg: 20px;
    
    /* Transitions */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header Styles */
header {
    background: var(--white);
    padding: 20px 0;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.596);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

/* Dark mystical theme option */
header h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.5rem;
    font-weight: 900;
    text-align: center;
    background: linear-gradient(135deg, #597ab8 0%, #2966cf 20%, #da5d5d 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 10px rgba(15, 12, 17, 0.4);
    letter-spacing: 3px;
    position: relative;
    text-transform: uppercase;
}

/* Dark glow effect */
header h1::before {
    content: "YuGiDex";
    position: absolute;
    top: 0;
    left: 0;
    z-index: -1;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #7e22ce 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: blur(10px);
    opacity: 0.6;
}

.search-container {
    display: flex;
    align-items: center;
    flex: 1;
    max-width: 400px;
}

#searchInput {
    padding: 12px 20px;
    font-size: 16px;
    border: 2px solid var(--medium-gray);
    border-radius: var(--border-radius-lg);
    width: 100%;
    background: var(--white);
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

#searchInput:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(58, 134, 255, 0.2);
}

#searchBtn {
    padding: 12px 20px;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #7e22ce 100%);
    color: var(--white);
    border: none;
    border-radius: var(--border-radius-lg);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-left: 10px;
    box-shadow: var(--shadow-md);
}

#searchBtn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--primary-color);
    cursor: pointer;
    padding: 10px;
}

/* Main Container */
.main-container {
    display: flex;
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Sidebar Styles */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    padding: 30px 20px;
    box-shadow: var(--shadow-md);
    overflow-y: auto;
    max-height: calc(100vh - 100px);
    position: sticky;
    top: 100px;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 13px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--medium-gray);
}

.sidebar-header h3 {
    color: var(--primary-color);
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.clear-filters {
    background: var(--secondary-color);
    color: var(--white);
    border: none;
    padding: 8px 15px;
    border-radius: var(--border-radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

.clear-filters:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.filter-section {
    margin-bottom: 30px;
}

.filter-section h4 {
    color: var(--dark-gray);
    font-size: 1rem;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.filter-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.filter-option {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 0px 12px;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
}

.filter-option:hover {
    background: var(--white);
    box-shadow: var(--shadow-sm);
}

.filter-option input[type="radio"] {
    accent-color: var(--primary-color);
}

.filter-option span {
    font-weight: 500;
}

.sidebar-select {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid var(--medium-gray);
    border-radius: var(--border-radius-md);
    background: var(--white);
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
}

.sidebar-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(58, 134, 255, 0.2);
}

.attribute-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.attribute-option {
    display:block;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.attribute-option input[type="radio"] {
    display: none;
}

.attr-icon {
    display: block;
    padding: 8px 12px;
    border-radius: var(--border-radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    transition: var(--transition);
    border: 2px solid transparent;
}

.attr-icon.all {
    background: var(--medium-gray);
    color: var(--dark-gray);
}

.attr-icon.dark {
    background: #4a4a4a;
    color: var(--white);
}

.attr-icon.divine {
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    color: #8b4513;
}

.attr-icon.earth {
    background: #8b4513;
    color: var(--white);
}

.attr-icon.fire {
    background: #dc143c;
    color: var(--white);
}

.attr-icon.light {
    background: #f0e68c;
    color: #8b4513;
}

.attr-icon.water {
    background: #4682b4;
    color: var(--white);
}

.attr-icon.wind {
    background: #90ee90;
    color: #2e8b57;
}

.attribute-option input[type="radio"]:checked + .attr-icon {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(58, 134, 255, 0.2);
    transform: scale(1.05);
}

.filter-stats {
    margin-top: 30px;
    padding: 15px;
    background: var(--white);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
    text-align: center;
}

.filter-stats p {
    color: var(--dark-gray);
    font-size: 0.9rem;
}

.filter-stats span {
    color: var(--primary-color);
    font-weight: 700;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 30px 20px;
    overflow-y: auto;
}

/* Enhanced Loading Animation */
.loading {
    text-align: center;
    padding: 50px;
    font-size: 1.5rem;
    color: var(--dark-gray);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.loading-spinner {
    width: 80px;
    height: 80px;
    position: relative;
    margin: 20px auto;
}

/* Yu-Gi-Oh! themed spinner */
.ygo-spinner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    animation: ygo-spin 2s infinite linear;
}

.ygo-spinner::before,
.ygo-spinner::after {
    content: "";
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 4px solid transparent;
}

.ygo-spinner::before {
    border-top-color: var(--primary-color);
    border-right-color: var(--info-color);
    animation: ygo-spin-top 1.5s infinite linear;
}

.ygo-spinner::after {
    border-bottom-color: var(--secondary-color);
    border-left-color: var(--accent-color);
    animation: ygo-spin-bottom 1.5s infinite linear;
}

/* Card flip animation */
.card-flip-container {
    width: 60px;
    height: 80px;
    position: relative;
    margin: 20px auto;
    perspective: 1000px;
}

.card-flip {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    animation: card-flip 1.5s infinite ease-in-out;
}

.card-flip-front,
.card-flip-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.card-flip-front {
    background: linear-gradient(135deg, var(--primary-color), var(--info-color));
    z-index: 2;
}

.card-flip-back {
    background: linear-gradient(135deg, var(--secondary-color), var(--accent-color));
    transform: rotateY(180deg);
}

/* Progress bar */
.loading-progress {
    width: 300px;
    height: 6px;
    background-color: var(--medium-gray);
    border-radius: 3px;
    margin: 20px auto;
    overflow: hidden;
    position: relative;
}

.loading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--info-color), var(--secondary-color));
    border-radius: 3px;
    width: 0%;
    animation: loading-progress 2s infinite ease-in-out;
}

/* Loading text with glow effect */
.loading-text {
    margin-top: 15px;
    font-weight: 600;
    color: var(--primary-color);
    text-shadow: 0 0 10px rgba(58, 134, 255, 0.3);
    animation: pulse-text 1.5s infinite ease-in-out;
}

/* Duel disk spinner */
.duel-disk {
    width: 100px;
    height: 100px;
    position: relative;
    margin: 20px auto;
}

.duel-disk-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 8px solid transparent;
    border-radius: 50%;
    box-sizing: border-box;
}

.duel-disk-ring:nth-child(1) {
    border-top-color: var(--primary-color);
    animation: duel-disk-spin 1.5s infinite linear;
}

.duel-disk-ring:nth-child(2) {
    border-right-color: var(--info-color);
    width: 80%;
    height: 80%;
    top: 10%;
    left: 10%;
    animation: duel-disk-spin 1.2s infinite linear reverse;
}

.duel-disk-ring:nth-child(3) {
    border-bottom-color: var(--secondary-color);
    width: 60%;
    height: 60%;
    top: 20%;
    left: 20%;
    animation: duel-disk-spin 1s infinite linear;
}

.duel-disk-center {
    position: absolute;
    width: 40%;
    height: 40%;
    top: 30%;
    left: 30%;
    background: linear-gradient(135deg, var(--accent-color), var(--primary-color));
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(58, 134, 255, 0.5);
}

/* Animations */
@keyframes ygo-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes ygo-spin-top {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes ygo-spin-bottom {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(-360deg); }
}

@keyframes card-flip {
    0% { transform: rotateY(0deg); }
    50% { transform: rotateY(180deg); }
    100% { transform: rotateY(360deg); }
}

@keyframes loading-progress {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

@keyframes pulse-text {
    0% { opacity: 0.7; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

@keyframes duel-disk-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Loading container with dark overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay.dark {
    background-color: rgba(0, 0, 0, 0.8);
}

.loading-overlay.dark .loading-text {
    color: var(--white);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}


.retry-btn {
    margin-top: 20px;
    padding: 10px 20px;
    background: linear-gradient(45deg, var(--primary-color), var(--info-color));
    color: white;
    border: none;
    border-radius: var(--border-radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
}

.retry-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.loading-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}



/* Card Grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 25px;
    padding: 20px 0;
}

.card {
    background: var(--white);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
    position: relative;
}

.card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(135deg, #597ab8 0%, #638ace 20%, #c97777 100%);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.card:hover::before {
    transform: scaleX(1);
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-xl);
}

.card img {
    width: calc(100% - 20px);
    height: 280px;
    object-fit: contain;
    transition: var(--transition);
    margin: 10px;
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
}

.card:hover img {
    transform: scale(1.03);
    box-shadow: var(--shadow-md);
}

.card-info {
    padding: 15px;
}

.card-name {
    font-weight: 700;
    font-size: 1rem;
    text-shadow: 
        0px 0px 2px rgba(56, 63, 75, 0.5),
        0px 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-color);
}

.card-type {
    font-size: 0.75rem;
    color: white;
    display: inline-block;
    padding: 6px 10px;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: var(--transition);
}

.card:hover .card-type {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    overflow-y: auto;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: var(--white);
    margin: 5% auto;
    padding: 30px;
    border-radius: var(--border-radius-lg);
    width: 90%;
    max-width: 900px;
    position: relative;
    box-shadow: var(--shadow-xl);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    color: var(--dark-gray);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close:hover {
    color: var(--white);
    background: var(--secondary-color);
}

.modal-card {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 30px;
}

.modal-card img {
    width: 100%;
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-lg);
}

.modal-card-info h2 {
    background: linear-gradient(135deg, #597ab8 0%, #2966cf 20%, #da5d5d 70%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 15px;
    font-size: 1.8rem;
    text-shadow: 10px 5px 4px rgba(0, 0, 0, 0.2);
}

.modal-card-info .card-details {
    margin: 15px 0;
}

.modal-card-info .card-details p {
    margin-bottom: 10px;
    display: flex;
}

.modal-card-info .card-details strong {
    color: var(--dark-gray);
    min-width: 100px;
    margin-right: 10px;
}

.modal-card-info .card-desc {
    background: var(--light-gray);
    padding: 15px;
    border-radius: var(--border-radius-md);
    margin-top: 15px;
    line-height: 1.6;
}

/* Pagination info styling */
.pagination-info {
    text-align: center;
    margin-bottom: 10px;
    color: var(--dark-gray);
    font-size: 0.9rem;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 30px 0;
    flex-wrap: wrap;
}


.pagination button {
    padding: 10px 15px;
    background: var(--white);
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius-md);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    align-items: center;
}

.pagination button:hover:not(:disabled) {
    background: var(--primary-color);
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.pagination button.active {
    background: var(--primary-color);
    color: var(--white);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Footer */
footer {
    text-align: center;
    padding: 10px 0;
    background: var(--white);
    margin-top: auto;
    box-shadow: 0 -4px 8px rgba(0,0,0,0.05);
    color: var(--dark-gray);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .sidebar {
        width: 250px;
    }
    
    .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

@media (max-width: 768px) {
    .sidebar-toggle {
        display: block;
    }
    
    .main-container {
        position: relative;
    }
    
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        height: 100vh;
        z-index: 200;
        transition: left 0.3s ease;
        box-shadow: var(--shadow-xl);
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .main-content {
        padding: 20px 15px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 15px;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .search-container {
        max-width: 100%;
    }
    
    .modal-card {
        grid-template-columns: 1fr;
    }
    
    .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 150;
}

.sidebar-overlay.active {
    display: block;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    display: none; /* Hidden by default, shown on mobile */
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--primary-color);
    cursor: pointer;
    padding: 10px;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: rgba(58, 134, 255, 0.1);
}

/* Sidebar Styles */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    padding: 30px 20px;
    box-shadow: var(--shadow-md);
    overflow-y: auto;
    max-height: calc(100vh - 100px);
    position: sticky;
    top: 100px;
    transition: transform 0.3s ease;
    /* Custom scrollbar styles */
    scrollbar-width: thin; /* For Firefox */
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent; /* For Firefox */
}

/* Webkit scrollbar styles (Chrome, Safari, Edge) */
.sidebar::-webkit-scrollbar {
    width: 8px;
}

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

.sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: content-box;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.7);
    background-clip: content-box;
}

/* For mobile sidebar */
.sidebar::-webkit-scrollbar-thumb:active {
    background-color: rgba(255, 255, 255, 0.9);
    background-clip: content-box;
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 150;
}

.sidebar-overlay.active {
    display: block;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .sidebar {
        width: 250px;
    }
    
    .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

@media (max-width: 768px) {
    /* Show the sidebar toggle button on mobile */
    .sidebar-toggle {
        display: block;
    }
    
    .main-container {
        position: relative;
    }
    
    /* Position sidebar off-screen on mobile */
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        height: 100vh;
        z-index: 200;
        transition: left 0.3s ease;
        box-shadow: var(--shadow-xl);
    }
    
    /* Show sidebar when active class is added */
    .sidebar.active {
        left: 0;
    }
    
    .main-content {
        padding: 20px 15px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 15px;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .search-container {
        max-width: 100%;
    }
    
    .modal-card {
        grid-template-columns: 1fr;
    }
    
    .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}