/* Bass Coast: The Gathering - Styling */

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

:root {
    --bg-dark: #1a1a1a;
    --bg-medium: #2a2a2a;
    --bg-light: #3a3a3a;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --accent: #00d4ff;
    --accent-hover: #00b8e6;
    --border: #444;
    --error: #ff4444;
    --success: #44ff44;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Login Page */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.login-container h1 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, var(--accent) 0%, #ff00ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-container form {
    background: var(--bg-medium);
    padding: 2rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    min-width: 300px;
}

.login-container label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.login-container input[type="text"] {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 1rem;
}

.login-container input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
}

.login-container button,
button {
    width: 100%;
    padding: 0.75rem;
    background: var(--accent);
    color: var(--bg-dark);
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.login-container button:hover,
button:hover {
    background: var(--accent-hover);
}

/* Main App Layout */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    background: var(--bg-medium);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
}

.header-left {
    display: flex;
    align-items: center;
}

.header-right {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

header h1 {
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--accent) 0%, #ff00ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.artist-selector {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: center;
}

.logout-button {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.logout-button:hover {
    background: var(--bg-light);
    border-color: var(--accent);
    color: var(--accent);
}

.artist-selector label {
    color: var(--text-secondary);
}

#artist-select {
    padding: 0.5rem 1rem;
    background: var(--bg-dark);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
    min-width: 300px;
    width: 300px;
}

#artist-select:focus {
    outline: none;
    border-color: var(--accent);
}

main {
    display: grid;
    grid-template-columns: 400px 1fr;
    flex: 1;
    overflow: visible;
}

/* Left Panel - Artist Details */
.left-panel {
    background: var(--bg-medium);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 2rem;
}

#artist-detail {
    color: var(--text-primary);
}

.save-section {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.artist-info h2,
.artist-info h3 {
    margin-bottom: 1rem;
    color: var(--accent);
}

.artist-info input[type="text"] {
    width: 100%;
    padding: 0.5rem;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

.artist-info table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.artist-info th,
.artist-info td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.artist-info th {
    color: var(--accent);
    font-weight: 600;
}

.artist-info dt {
    color: var(--accent);
    font-weight: 600;
    margin-top: 0.5rem;
}

.artist-info dd {
    margin-left: 1rem;
    margin-bottom: 0.5rem;
}

.actions {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.actions button {
    width: auto;
    padding: 0.5rem 1.5rem;
    margin-right: 0.5rem;
}

.save-button {
    background: var(--accent);
    color: var(--bg-dark);
    font-weight: 600;
}

.save-button:hover:not(:disabled) {
    background: var(--accent-hover);
}

.save-button:disabled {
    background: var(--bg-light);
    color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.5;
}

.delete-button {
    background: var(--error);
    color: white;
    font-weight: 600;
    width: auto;
    padding: 0.5rem 1.5rem;
    margin-left: 0.5rem;
}

.delete-button:hover {
    background: #cc0000;
}

.save-status {
    display: inline-block;
    margin-left: 1rem;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

.save-status.success {
    background: rgba(68, 255, 68, 0.2);
    color: var(--success);
    border: 1px solid var(--success);
}

.save-status.error {
    background: rgba(255, 68, 68, 0.2);
    color: var(--error);
    border: 1px solid var(--error);
}

/* Metadata Section */
#metadata-section {
    margin-top: 1.5rem;
}

.metadata-field {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.metadata-field label {
    width: 140px;
    flex-shrink: 0;
    color: var(--accent);
    font-weight: 600;
    font-size: 1rem;
    padding: 0.75rem 0;
    display: flex;
    align-items: center;
}

.metadata-field input[type="text"] {
    flex: 1;
    padding: 0.75rem;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 1rem;
    min-height: 44px;
}

.metadata-field input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
}

.delete-field-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    padding: 0.25rem 0.5rem;
    transition: all 0.2s;
    width: auto;
    min-width: 44px;
    height: 44px;
}

.delete-field-btn:hover {
    background: var(--error);
    border-color: var(--error);
    color: white;
}

/* New field section - stack inputs vertically for better spacing */
.metadata-new-field {
    background: var(--bg-light);
    padding: 1.5rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    margin-top: 2rem;
    margin-bottom: 1.5rem;
}

.metadata-new-field h4 {
    margin-bottom: 1rem;
    color: var(--accent);
}

.metadata-new-field-row {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.metadata-new-field input[type="text"] {
    padding: 0.75rem;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 1rem;
    min-height: 44px;
}

.metadata-new-field input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
}

#add-metadata-field,
#save-metadata {
    width: auto;
    padding: 0.75rem 1.5rem;
    margin-top: 0.5rem;
    font-size: 1rem;
}

#save-metadata {
    margin-top: 1.5rem;
}

/* MTG Card Section */
.mtg-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.mtg-section h3 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

.mtg-section h3:first-of-type {
    margin-top: 0;
}

.mtg-section p {
    margin-bottom: 1.5rem;
}

.card-list {
    list-style: none;
    margin-bottom: 1.5rem;
}

.card-item {
    padding: 0.75rem;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 4px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

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

.card-item small {
    color: var(--text-secondary);
}

/* MTG Search Filters */
.mtg-filters {
    background: var(--bg-dark);
    padding: 1.5rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.filter-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.filter-group {
    margin-bottom: 1rem;
}

.filter-group label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.filter-group select,
.filter-group input[type="number"],
.filter-group input[type="text"] {
    width: 100%;
    padding: 0.5rem;
    background: var(--bg-medium);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Search Help Icon */
.search-help-icon {
    display: inline-block;
    margin-left: 0.5rem;
    color: var(--accent);
    cursor: help;
    font-size: 0.9rem;
    font-weight: bold;
    border: 1px solid var(--accent);
    border-radius: 50%;
    width: 1.2rem;
    height: 1.2rem;
    text-align: center;
    line-height: 1.2rem;
    vertical-align: middle;
}

.search-help-icon:hover {
    background: var(--accent);
    color: var(--bg-dark);
}

/* Color Checkboxes */
.color-checkboxes {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.color-checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.color-checkbox input[type="checkbox"] {
    display: none;
}

.color-label {
    display: inline-block;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--border);
    text-align: center;
    line-height: 28px;
    font-weight: bold;
    transition: all 0.2s;
}

.color-checkbox input:checked + .color-label {
    border-width: 3px;
    box-shadow: 0 0 8px currentColor;
}

.color-label.white {
    background: #fffbd5;
    color: #333;
    border-color: #ffd700;
}

.color-checkbox input:checked + .color-label.white {
    border-color: #fffbd5;
    box-shadow: 0 0 8px #fffbd5;
}

.color-label.blue {
    background: #0e68ab;
    color: #fff;
    border-color: #0a4d7a;
}

.color-checkbox input:checked + .color-label.blue {
    border-color: #0e68ab;
}

.color-label.black {
    background: #150b00;
    color: #ccc;
    border-color: #333;
}

.color-checkbox input:checked + .color-label.black {
    border-color: #666;
}

.color-label.red {
    background: #d32029;
    color: #fff;
    border-color: #a01a20;
}

.color-checkbox input:checked + .color-label.red {
    border-color: #d32029;
}

.color-label.green {
    background: #00733e;
    color: #fff;
    border-color: #005530;
}

.color-checkbox input:checked + .color-label.green {
    border-color: #00733e;
}

.mtg-filters button[type="submit"] {
    width: 100%;
    margin-top: 0.5rem;
}

.card-search-results {
    min-height: 50px;
    max-height: 400px;
    overflow-y: auto;
}

.card-search-results p {
    margin-bottom: 0;
}

.card-search-results.htmx-request {
    opacity: 0.6;
    pointer-events: none;
}

/* Right Panel - 3D Card Viewer */
.right-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 2rem;
    padding-top: 4rem;
}

#card-viewer-container {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    gap: 1rem;
    align-items: center;
    justify-items: center;
    width: 100%;
    text-align: center;
}

#card-viewer-container h2 {
    margin-bottom: 1.5rem;
    color: var(--accent);
}

#card-viewer {
    grid-column: 2;
    grid-row: 1;
    width: 600px;
    height: min(800px, calc(100vh - 200px));
    background: var(--bg-medium);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.viewer-controls {
    grid-column: 2;
    grid-row: 2;
}

#toggle-rotation {
    margin-top: 1rem;
    width: auto;
    padding: 0.5rem 1.5rem;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* Loading States */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-request.htmx-indicator {
    display: inline-block;
}

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.loading-spinner.large {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

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

.loading-overlay {
    position: relative;
}

.loading-overlay::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 26, 26, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
}

.htmx-request.loading-overlay::after {
    display: flex;
}

/* Artist Navigation */
.nav-button {
    padding: 1rem 0.75rem;
    background: var(--bg-light);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    height: fit-content;
}

.nav-button.nav-left {
    grid-column: 1;
    grid-row: 1;
}

.nav-button.nav-right {
    grid-column: 3;
    grid-row: 1;
}

.nav-button:hover {
    background: var(--bg-medium);
    border-color: var(--accent);
    transform: scale(1.1);
}

.nav-button:active {
    transform: scale(0.95);
}

.nav-button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.nav-button:disabled:hover {
    transform: none;
}

.nav-arrow {
    font-size: 2rem;
    line-height: 1;
}

/* Mobile Tabs */
.mobile-tabs {
    display: none; /* Hidden on desktop */
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.5rem;
}

.tab-button {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
    margin-bottom: -2px;
}

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

.tab-button.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Desktop: All tab content visible by default */
.tab-content {
    display: block;
}

/* Mobile Responsive Design - Single breakpoint at 768px */
@media (max-width: 768px) {
    /* Login page - prevent zoom and reduce padding */
    .login-container {
        padding: 1rem;
    }

    .login-container h1 {
        font-size: 1.75rem;
        margin-bottom: 1.5rem;
    }

    .login-container form {
        width: 100%;
        max-width: 100%;
    }

    .login-container input,
    .login-container button {
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    /* Header */
    header {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        gap: 0.75rem;
        padding: 1rem;
    }

    .header-left {
        grid-row: 1;
        justify-content: center;
    }

    .artist-selector {
        grid-row: 2;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .header-right {
        grid-row: 3;
        justify-content: center;
    }

    header h1 {
        font-size: 1.25rem;
    }

    #artist-select {
        width: 100%;
        min-width: auto;
        font-size: 16px; /* Prevents iOS zoom */
    }

    /* Mobile layout: card viewer on top, artist details below */
    main {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        overflow-y: auto;
    }

    .right-panel {
        grid-row: 1; /* Card viewer shows first */
        padding: 1rem 0.5rem;
        border-bottom: 1px solid var(--border);
    }

    .left-panel {
        grid-row: 2; /* Artist details show second */
        max-height: none;
        border-right: none;
        padding: 0;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
    }

    /* Save section - fixed at top */
    .save-section {
        flex-shrink: 0;
        background: var(--bg-medium);
        padding: 1rem 1rem 0.5rem 1rem;
        margin: 0;
        border-bottom: 1px solid var(--border);
        flex-direction: column;
        align-items: stretch;
    }

    /* Enable mobile tabs - sticky below save section */
    .mobile-tabs {
        display: flex !important;
        flex-shrink: 0;
        gap: 0.5rem;
        overflow-x: auto;
        background: var(--bg-medium);
        padding: 0.5rem 1rem;
        margin: 0;
        border-bottom: 2px solid var(--border);
        position: sticky;
        top: 0;
        z-index: 100;
    }

    /* Tab content wrapper for scrolling */
    .tab-content {
        display: none !important;
        flex: 1;
        overflow-y: auto;
        padding: 1rem;
        min-height: 0; /* Important for flex children to scroll */
    }

    .tab-content.active {
        display: block !important;
    }

    .artist-info input[type="text"],
    .metadata-input,
    #new-field-name,
    #new-field-value {
        font-size: 16px; /* Prevents iOS zoom */
    }

    .save-button,
    .delete-button {
        width: 100%;
        margin-left: 0;
        margin-bottom: 0.5rem;
    }

    /* MTG filters */
    .mtg-filters {
        padding: 1rem;
    }

    .mtg-filters input,
    .mtg-filters select {
        font-size: 16px; /* Prevents iOS zoom */
    }

    .filter-row {
        grid-template-columns: 1fr;
    }

    .color-checkboxes {
        justify-content: space-between;
    }

    .color-label {
        width: 44px; /* Larger touch target */
        height: 44px;
        line-height: 40px;
    }

    /* Card viewer - larger on mobile */
    #card-viewer-container {
        display: grid;
        grid-template-columns: 60px 1fr 60px;
        grid-template-rows: auto auto;
        gap: 0.5rem;
        align-items: center;
        justify-items: center;
    }

    #card-viewer {
        grid-column: 2;
        grid-row: 1;
        width: 100%;
        max-width: 100%;
        height: 50vh; /* Fixed height that's large enough to see card clearly */
        max-height: 50vh;
    }

    .viewer-controls {
        grid-column: 1 / -1;
        grid-row: 2;
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
    }

    /* Navigation buttons - larger touch targets, fixed width for centering */
    .nav-button {
        width: 50px;
        height: 80px;
        padding: 0;
        font-size: 1.75rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .nav-button.nav-left {
        grid-column: 1;
        grid-row: 1;
    }

    .nav-button.nav-right {
        grid-column: 3;
        grid-row: 1;
    }

    .nav-arrow {
        font-size: 2.5rem;
    }

    .actions button {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .metadata-field {
        flex-direction: column;
        align-items: flex-start;
    }

    .metadata-field label {
        margin-bottom: 0.5rem;
    }

    .metadata-new-field-row {
        grid-template-columns: 1fr;
    }

    /* Card list items - larger touch targets */
    .card-item {
        padding: 1rem;
        font-size: 1rem;
    }

    /* Tables */
    table {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .login-container h1 {
        font-size: 1.75rem;
    }

    .login-container form {
        min-width: auto;
        width: 100%;
        padding: 1.5rem;
    }

    header h1 {
        font-size: 1.1rem;
    }

    .artist-info h2,
    .artist-info h3 {
        font-size: 1.1rem;
    }

    .artist-info table {
        font-size: 0.9rem;
    }

    .artist-info th,
    .artist-info td {
        padding: 0.5rem;
    }

    #card-viewer {
        max-width: 250px;
        height: 35vh;
        max-height: 35vh; /* Responsive height for small screens */
    }
}
