/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #FF6B35;
    --secondary-color: #4A90E2;
    --success-color: #7EC850;
    --danger-color: #EF4444;
    --dark-bg: #1F2937;
    --light-bg: #F9FAFB;
    --card-bg: #FFFFFF;
    --text-primary: #111827;
    --text-secondary: #6B7280;
    --border-color: #E5E7EB;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-primary);
    min-height: 100vh;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--light-bg);
    min-height: 100vh;
    box-shadow: var(--shadow-lg);
}

/* Header */
.app-header {
    background: linear-gradient(135deg, #FF6B35 0%, #FF8E53 100%);
    color: white;
    padding: 2rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.app-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
}

.community-count {
    font-size: 0.9rem;
    opacity: 0.85;
    margin-top: 0.25rem;
}

/* Set Selector */
.set-selector-container {
    background: var(--card-bg);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
    border-bottom: 2px solid var(--border-color);
}

.set-selector-label {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.set-selector {
    flex: 1;
    max-width: 400px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: white;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.set-selector:hover {
    border-color: var(--primary-color);
}

.set-selector:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

/* Navigation */
.app-nav {
    background: var(--card-bg);
    padding: 1rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
    box-shadow: var(--shadow);
    flex-wrap: wrap;
}

.nav-btn {
    padding: 0.75rem 1.5rem;
    border: 2px solid var(--border-color);
    background: white;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-btn:hover {
    border-color: var(--primary-color);
    background: var(--light-bg);
    transform: translateY(-2px);
}

.nav-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.nav-btn .icon {
    font-size: 1.2rem;
}

/* Main Content */
.app-main {
    padding: 2rem;
    min-height: 600px;
}

.view {
    display: none;
}

.view.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* Controls Panel */
.controls-panel {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.search-box {
    margin-bottom: 1rem;
}

.search-box input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.filters {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-select {
    flex: 1;
    min-width: 150px;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    background: var(--text-secondary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: var(--text-primary);
    transform: translateY(-2px);
}

/* Collection Summary */
.collection-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.summary-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: center;
}

.summary-card h3 {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.75rem;
}

.summary-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.progress-bar {
    background: var(--border-color);
    height: 12px;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    background: linear-gradient(90deg, var(--success-color), var(--primary-color));
    height: 100%;
    transition: width 0.5s ease;
}

.summary-percentage {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}

.summary-note {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

/* Card Grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.card-item {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.card-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.card-item.owned {
    border: 3px solid var(--success-color);
}

.card-sequence-number {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 10;
    border: 2px solid white;
}

.card-checkbox {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    cursor: pointer;
    z-index: 10;
    accent-color: var(--success-color);
}

/* Variant Checkboxes */
.card-variants {
    position: absolute;
    bottom: 145px;
    right: 10px;
    display: flex;
    flex-direction: row;
    gap: 0.75rem;
    z-index: 10;
    background: rgba(255, 255, 255, 0.95);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border: 2px solid var(--border-color);
}

.variant-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.variant-checkbox-input {
    position: static !important; /* Override absolute positioning from .card-checkbox */
    width: 24px !important;
    height: 24px !important;
    cursor: pointer;
    accent-color: var(--success-color);
    margin: 0 !important;
}

.variant-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    cursor: pointer;
    user-select: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
}

/* Checkbox sequence number badge */
.checkbox-sequence-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.55rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    border: 1.5px solid white;
    flex-shrink: 0;
}

/* Single checkbox wrapper for non-variant cards */
.single-checkbox-wrapper {
    position: absolute;
    bottom: 145px;
    right: 10px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    z-index: 10;
    background: rgba(255, 255, 255, 0.95);
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border: 2px solid var(--border-color);
}

.single-checkbox-wrapper .card-checkbox {
    position: static;
    width: 24px;
    height: 24px;
    margin: 0;
}

.card-image-container {
    position: relative;
    padding-top: 140%; /* Aspect ratio for Pokemon cards */
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    overflow: hidden;
}

.card-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-secondary);
    padding: 1rem;
}

.card-placeholder .card-number {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.card-info {
    padding: 1rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 0.5rem;
}

.card-number-badge {
    background: var(--dark-bg);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
}

.card-type-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    color: white;
}

.card-name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.card-rarity {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.card-price {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--primary-color);
}

.price-loading {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Statistics View */
.stats-container h2 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.stat-card h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.stat-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: var(--light-bg);
    border-radius: 6px;
}

.stat-label {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-badge {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.stat-value {
    font-weight: bold;
    color: var(--primary-color);
}

.stats-visual {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.stats-visual h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.visual-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 0.5rem;
}

.visual-card {
    aspect-ratio: 0.7;
    border-radius: 4px;
    border: 2px solid var(--border-color);
    background: var(--light-bg);
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.visual-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.visual-card.owned {
    border-color: var(--success-color);
    opacity: 1;
}

.visual-card:not(.owned) {
    opacity: 0.3;
}

.visual-card:hover {
    transform: scale(1.1);
    z-index: 10;
}

.missing-cards {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.missing-cards h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.missing-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: modalSlideIn 0.3s ease;
}

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

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

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

.modal-card-detail {
    text-align: center;
}

.modal-card-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin-bottom: 1rem;
}

/* Footer */
.app-footer {
    background: var(--dark-bg);
    color: white;
    padding: 2rem;
    text-align: center;
    margin-top: 3rem;
}

.app-footer p {
    margin-bottom: 0.5rem;
}

.footer-note {
    font-size: 0.85rem;
    opacity: 0.8;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-header h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .app-main {
        padding: 1rem;
    }

    .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1rem;
    }

    .filters {
        flex-direction: column;
    }

    .filter-select {
        width: 100%;
    }

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

/* Utility Classes */
.text-center {
    text-align: center;
}

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.hidden {
    display: none !important;
}

/* Settings View */
.settings-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

.settings-container h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

.settings-section {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.settings-section h3 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.settings-description {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.settings-description a {
    color: var(--secondary-color);
    text-decoration: none;
}

.settings-description a:hover {
    text-decoration: underline;
}

.api-key-container {
    margin-top: 1rem;
}

.api-key-container label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.api-key-input-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.api-key-input {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    font-family: 'Courier New', monospace;
}

.api-key-input:focus {
    outline: none;
    border-color: var(--secondary-color);
}

.btn-icon {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-bg);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

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

.btn-primary {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    background: var(--secondary-color);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: #3A80D2;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--light-bg);
    border-color: var(--text-secondary);
}

.api-status {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--light-bg);
    border-radius: 6px;
    border-left: 4px solid var(--secondary-color);
}

.api-status.success {
    border-left-color: var(--success-color);
    background: #f0fdf4;
}

.api-status.error {
    border-left-color: var(--danger-color);
    background: #fef2f2;
}

.settings-note {
    margin-top: 1rem;
    padding: 1rem;
    background: #fffbeb;
    border-left: 4px solid #f59e0b;
    border-radius: 6px;
    color: #92400e;
    font-size: 0.9rem;
}

.backup-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.backup-buttons button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.setting-item {
    margin-bottom: 1rem;
}

.setting-item label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--text-primary);
}

.setting-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.info-list {
    list-style: none;
    padding-left: 0;
}

.info-list li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
    color: var(--text-secondary);
}

.info-list li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success-color);
    font-weight: bold;
}

/* Color Picker Styles */
.color-picker-container {
    margin-top: 1rem;
}

.color-picker-container > label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.color-picker-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.color-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.color-preset {
    width: 40px;
    height: 40px;
    border: 3px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.color-preset:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.color-preset.active {
    border-color: var(--text-primary);
    transform: scale(1.1);
}

.custom-color-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.custom-color-row label {
    font-weight: 500;
    color: var(--text-secondary);
}

.color-input {
    width: 50px;
    height: 40px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    padding: 2px;
    background: white;
}

.color-input::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.color-input::-webkit-color-swatch {
    border-radius: 4px;
    border: none;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

/* ================================
   Authentication Overlay Styles
   ================================ */

.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.auth-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.auth-container {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    margin: 1rem;
    animation: slideUp 0.4s ease;
}

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

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo {
    width: 80px;
    height: auto;
    margin-bottom: 1rem;
}

.auth-header h1 {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.auth-header .auth-version {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0;
    border-top: none;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
    opacity: 0.7;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.auth-form h2 {
    text-align: center;
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: var(--light-bg);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

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

.auth-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: #dc2626;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    display: none;
}

.auth-error.show {
    display: block;
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.auth-btn {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.auth-btn.primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, #FF8E53 100%);
    color: white;
}

.auth-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.4);
}

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

.auth-switch {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.auth-switch a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* ================================
   User Controls in Header
   ================================ */

.app-header {
    position: relative;
}

.header-logo-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.header-logo {
    width: 60px;
    height: auto;
}

.header-version {
    font-size: 0.7rem;
    font-family: 'Courier New', monospace;
    background: rgba(255, 255, 255, 0.2);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.8);
}

.user-controls {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
}

.user-icon {
    font-size: 1.1rem;
}

.logout-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

.settings-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: rotate(45deg);
}

/* Responsive adjustments for user controls */
@media (max-width: 768px) {
    .user-controls {
        position: static;
        justify-content: center;
        margin-top: 1rem;
        padding-bottom: 0.5rem;
    }

    .auth-container {
        padding: 1.5rem;
    }

    .auth-header h1 {
        font-size: 1.5rem;
    }
}

/* ================================
   Binder View Styles
   ================================ */

.binder-container {
    max-width: 900px;
    margin: 0 auto;
}

.binder-container h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.binder-subtitle {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.binder-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
    background: var(--card-bg);
    padding: 1rem 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.binder-nav-btn {
    padding: 0.75rem 1.5rem;
    border: 2px solid var(--border-color);
    background: white;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.binder-nav-btn:hover:not(:disabled) {
    border-color: var(--primary-color);
    background: var(--light-bg);
    transform: translateY(-2px);
}

.binder-nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.binder-page-info {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.binder-page {
    background: linear-gradient(135deg, #2c1810 0%, #4a3728 50%, #2c1810 100%);
    border-radius: 16px;
    padding: 2rem;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.3),
        inset 0 2px 4px rgba(255, 255, 255, 0.1),
        inset 0 -2px 4px rgba(0, 0, 0, 0.2);
    border: 4px solid #1a0f0a;
    position: relative;
}

.binder-page::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(to bottom, #1a0f0a 0%, #3d2a1f 50%, #1a0f0a 100%);
    transform: translateX(-50%);
    box-shadow:
        -2px 0 4px rgba(0, 0, 0, 0.3),
        2px 0 4px rgba(0, 0, 0, 0.3);
}

.binder-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 1.5rem;
    aspect-ratio: 3 / 4;
}

.binder-slot {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
}

.binder-slot:hover {
    transform: scale(1.02);
    border-color: var(--primary-color);
    box-shadow: 0 4px 20px rgba(255, 107, 53, 0.3);
}

.binder-slot.owned {
    border-color: var(--success-color);
    box-shadow: 0 0 15px rgba(126, 200, 80, 0.3);
}

.binder-slot.missing {
    border-color: var(--danger-color);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.3);
}

.binder-slot-image-faded {
    opacity: 0.3;
    filter: grayscale(30%);
}

.binder-slot-missing-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--danger-color);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.binder-slot-number {
    position: absolute;
    top: 8px;
    left: 8px;
    min-width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    padding: 0 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 10;
    border: 2px solid white;
}

.binder-slot-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px;
    transition: transform 0.3s ease;
}

.binder-slot:hover .binder-slot-image {
    transform: scale(1.05);
}

.binder-slot-empty {
    color: rgba(255, 255, 255, 0.3);
    text-align: center;
    padding: 1rem;
}

.binder-slot-empty .empty-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    display: block;
}

.binder-slot-empty .empty-text {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.binder-slot-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0) 100%);
    padding: 2rem 0.5rem 0.5rem;
    color: white;
    text-align: center;
}

.binder-slot-name {
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.binder-slot-variant {
    font-size: 0.6rem;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.binder-slot-owned-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--success-color);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

/* Binder Page Slider */
.binder-slider-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    background: var(--card-bg);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.binder-slider-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 24px;
    text-align: center;
}

.binder-slider {
    flex: 1;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-color);
    border-radius: 4px;
    outline: none;
    cursor: pointer;
    transition: background 0.2s ease;
}

.binder-slider:hover {
    background: #d1d5db;
}

/* Slider Track */
.binder-slider::-webkit-slider-runnable-track {
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right,
        var(--primary-color) 0%,
        var(--primary-color) var(--slider-progress, 0%),
        var(--border-color) var(--slider-progress, 0%),
        var(--border-color) 100%);
}

.binder-slider::-moz-range-track {
    height: 8px;
    border-radius: 4px;
    background: var(--border-color);
}

.binder-slider::-moz-range-progress {
    height: 8px;
    border-radius: 4px;
    background: var(--primary-color);
}

/* Slider Thumb */
.binder-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #FF8E53 100%);
    border-radius: 50%;
    cursor: grab;
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.4);
    border: 3px solid white;
    margin-top: -8px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.binder-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.5);
}

.binder-slider::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.15);
}

.binder-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #FF8E53 100%);
    border-radius: 50%;
    cursor: grab;
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.4);
    border: 3px solid white;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.binder-slider::-moz-range-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.5);
}

/* Responsive Binder */
@media (max-width: 768px) {
    .binder-page {
        padding: 1rem;
    }

    .binder-grid {
        gap: 0.75rem;
    }

    .binder-controls {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .binder-slider-container {
        padding: 0.75rem 1rem;
    }

    .binder-slot-number {
        min-width: 22px;
        height: 22px;
        font-size: 0.65rem;
    }

    .binder-slot-name {
        font-size: 0.6rem;
    }

    .binder-slot-variant {
        font-size: 0.5rem;
    }
}

/* ================================
   My Binder View Styles
   ================================ */

.mybinder-subtitle {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.mybinder-stats {
    display: inline-block;
    background: linear-gradient(135deg, var(--success-color) 0%, #9BD870 100%);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(126, 200, 80, 0.3);
}

.mybinder-empty {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 4rem 2rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.mybinder-empty .empty-state {
    max-width: 300px;
    margin: 0 auto;
}

.mybinder-empty .empty-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 1rem;
}

.mybinder-empty h3 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.mybinder-empty p {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ================================
   Avery Binder Labels Styles
   ================================ */

/* Button container in My Binder view */
.binder-labels-btn-container {
    margin-bottom: 1.5rem;
}

.avery-labels-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #9B59B6 0%, #B07CC6 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(155, 89, 182, 0.3);
}

.avery-labels-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(155, 89, 182, 0.4);
    background: linear-gradient(135deg, #8E44AD 0%, #A569BD 100%);
}

/* Avery Labels Modal */
.avery-labels-modal-content {
    max-width: 800px;
    width: 95%;
}

.avery-labels-header {
    text-align: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.avery-labels-header h2 {
    font-size: 1.75rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.avery-labels-description {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.avery-labels-info {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.info-badge {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Labels Preview */
.avery-labels-preview {
    background: var(--light-bg);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.avery-labels-preview h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.avery-labels-preview h3 span {
    font-weight: 400;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.avery-labels-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 0.75rem;
    max-height: 300px;
    overflow-y: auto;
    padding: 0.5rem;
}

.avery-label-preview {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4px;
    box-sizing: border-box;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.avery-label-preview.avery-label-ex {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

.avery-label-name {
    color: white;
    font-weight: 600;
    font-size: 0.4rem;
    line-height: 1.1;
    text-align: center;
    max-width: 42px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.avery-label-number {
    color: white;
    font-weight: 700;
    font-size: 0.75rem;
    line-height: 1;
}

.avery-label-ex-text {
    color: white;
    font-weight: 700;
    font-size: 0.6rem;
    text-transform: lowercase;
    font-style: italic;
    line-height: 1;
    margin-top: 1px;
}

/* Labels Actions */
.avery-labels-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.avery-labels-actions button {
    min-width: 150px;
}

/* Print Container (hidden on screen) */
.avery-labels-print-container {
    display: none;
}

/* ================================
   Avery Labels Print Styles
   Presta 94504 Format:
   - 0.75" (3/4") diameter circular labels
   - 8 columns x 10 rows = 80 labels per page
   - Letter size (8.5" x 11")
   ================================ */

@media print {
    /* Reset everything for clean print */
    *, *::before, *::after {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }

    html, body {
        width: 8.5in;
        height: auto;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        background: white;
    }

    /* Hide everything except print container */
    body > *:not(.avery-labels-print-container) {
        display: none !important;
        height: 0 !important;
        overflow: hidden !important;
    }

    .avery-labels-print-container {
        display: block !important;
        position: static !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 8.5in;
        overflow: hidden;
    }

    /* Label Sheet - Letter size */
    .avery-label-sheet {
        width: 8.5in;
        max-height: 10.5in;
        padding-top: 0.5in;    /* Top margin */
        padding-left: 0.25in;  /* Left margin: (8.5" - 8 cols × 1.0") / 2 */
        padding-right: 0.25in;
        padding-bottom: 0;
        margin: 0;
        box-sizing: border-box;
        overflow: hidden;
        background: white;
        /* Modern break properties for Chrome */
        break-after: auto;
        break-inside: avoid;
        page-break-after: auto;
        page-break-inside: avoid;
    }

    /* Label Row */
    .avery-label-row {
        display: flex;
        justify-content: flex-start;
        height: 1.0in; /* Row height: vertical pitch for 10 rows */
        margin: 0;
        padding: 0;
    }

    /* Individual Label - 0.75" diameter circle */
    .avery-label {
        width: 1.0in;   /* Cell width: horizontal pitch for 8 columns */
        height: 1.0in;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }

    .avery-label-text {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 0.75in;   /* Label diameter */
        height: 0.75in;
        padding: 0.05in;
        box-sizing: border-box;
        border-radius: 50%;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        font-weight: 700;
        font-size: 12pt;
        font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .avery-label-text-ex {
        background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    }

    .avery-label-name-print {
        font-size: 5pt;
        font-weight: 600;
        line-height: 1.1;
        text-align: center;
        max-width: 0.6in;
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    .avery-label-num {
        line-height: 1;
    }

    .avery-label-ex-print {
        font-size: 8pt;
        font-style: italic;
        text-transform: lowercase;
        line-height: 1;
        margin-top: 1px;
    }

    .avery-label-empty {
        /* Empty labels - no visual content */
    }

    /* Print settings - Chrome specific */
    @page {
        size: 8.5in 11in;
        margin: 0;
    }

    @page :first {
        margin: 0;
    }
}
