/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    /* fallback for light mode */
    background: #fff;
    color: #222;
    margin: 0;
    margin-top: 8px;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    text-align: center;
    margin-top: 0;
}

#demo-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-left: 0;
}

#demo-list li {
    width: 40%;
    margin: 8px auto;
    display: block;
    /* Basic styling for list items (adjust as needed) */
    padding: 8px 12px;
    margin-bottom: 4px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;

    /* Crucial part for animation */
    transition: transform 0.2s ease-in-out;
    /* Adjust timing/easing as needed */
    cursor: grab;
}

#demo-list li.is-moving-demo {
    /* Optional: Style while moving (e.g., slight shadow, opacity) */
    opacity: 0.8;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Dark mode support - Modern 2025 color palette */
/* Using softer dark grays with subtle blue tint for better eye comfort */
@media (prefers-color-scheme: dark) {
    :root {
        /* Background layers (depth through elevation) */
        --bg-base: #0f1419;
        --bg-surface: #1a1f2e;
        --bg-elevated: #252b3b;
        --bg-hover: #2d3548;

        /* Text colors (high contrast for accessibility) */
        --text-primary: #f0f2f5;
        --text-secondary: #a8b3cf;
        --text-muted: #6b7a99;

        /* Accent colors (vibrant but not harsh) */
        --accent-primary: #818cf8;
        --accent-link: #60a5fa;
        --accent-link-hover: #93c5fd;
        --accent-success: #34d399;
        --accent-warning: #fbbf24;

        /* Borders */
        --border-subtle: #2d3548;
        --border-default: #3d4663;
    }

    body {
        background-color: var(--bg-base);
        color: var(--text-primary);
    }

    h1,
    h2,
    h3,
    h4,
    h5,
    h6 {
        color: var(--text-primary);
    }

    /* Links - bright and visible */
    a {
        color: var(--accent-link);
        transition: color 0.2s ease;
    }

    a:hover {
        color: var(--accent-link-hover);
    }

    a:visited {
        color: #a78bfa;
    }

    #demo-list li {
        background-color: var(--bg-surface);
        border: 1px solid var(--border-subtle);
        color: var(--text-primary);
    }

    #demo-list li:hover {
        background-color: var(--bg-elevated);
        border-color: var(--border-default);
    }
}

/* Navbar styles */
.navbar {
    width: 100%;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
    padding: 0.5rem 0;
    margin-bottom: 1.5rem;
}

.navbar-links {
    display: flex;
    flex-direction: row;
    justify-content: center;
    list-style: none;
    padding: 0;
    margin: 0;
}

.navbar-links li {
    margin: 0 1rem;
}

.navbar-links a {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
}

.navbar-links .active a,
.navbar-links li.active a {
    background: #007bff;
    color: #fff;
}

@media (prefers-color-scheme: dark) {
    .navbar {
        background: var(--bg-surface);
        border-bottom: 1px solid var(--border-subtle);
    }

    .navbar-links a {
        color: var(--text-secondary);
    }

    .navbar-links a:hover {
        color: var(--text-primary);
        background: var(--bg-elevated);
    }

    .navbar-links .active a,
    .navbar-links li.active a {
        background: var(--accent-primary);
        color: #fff;
    }
}

/* Flash message styles */
.flash-message {
    position: fixed;
    top: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    min-width: 200px;
    max-width: 90vw;
    z-index: 1000;
    padding: 1rem 2rem;
    border-radius: 6px;
    font-weight: bold;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    opacity: 1;
    transition: opacity 0.5s;
}

.notice {
    background: #e0f7fa;
    color: #007b83;
    border: 1px solid #b2ebf2;
}

.alert {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

/* Ranking Interface Styles */
.rank-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
}

.ranking-frame {
    display: block;
    width: 100%;
}

#ranking-interface-content {
    background-color: #f9f9f9;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.batch-info {
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: #555;
}

.batch-number {
    font-weight: bold;
    color: #333;
}

/* Progress Indicator Styles */
.progress-indicator {
    text-align: center;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: #f5f5f5;
    border-radius: 8px;
}

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

.confidence-value {
    font-weight: bold;
    color: #4a6bdf;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4a6bdf, #6b8cff);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-details {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #666;
}

.phase-indicator {
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-weight: 500;
}

.phase-exploration {
    background: #fff3e0;
    color: #e65100;
}

.phase-refinement {
    background: #e3f2fd;
    color: #1565c0;
}

.phase-converged {
    background: #e8f5e9;
    color: #2e7d32;
}

.batches-remaining {
    font-style: italic;
}

.experiment-group-badge {
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    background: #f3e5f5;
    color: #7b1fa2;
    cursor: help;
}

/* Progress Indicator Dark Mode */
@media (prefers-color-scheme: dark) {
    #ranking-interface-content {
        background-color: var(--bg-surface);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }

    .batch-info {
        color: var(--text-secondary);
    }

    .progress-indicator {
        background: var(--bg-elevated);
    }

    .batch-number {
        color: var(--text-primary);
    }

    .progress-bar-container {
        background: var(--bg-hover);
    }

    .progress-bar-fill {
        background: linear-gradient(90deg, var(--accent-primary), var(--accent-link));
    }

    .progress-details {
        color: var(--text-secondary);
    }

    .confidence-value {
        color: var(--accent-link);
    }

    /* Phase indicators for dark mode */
    .phase-exploration {
        background: #3d2e1f;
        color: #fbbf24;
    }

    .phase-refinement {
        background: #1e2a3d;
        color: #60a5fa;
    }

    .phase-converged {
        background: #1a3329;
        color: #34d399;
    }

    .batches-remaining {
        color: var(--text-muted);
    }

    .experiment-group-badge {
        background: #2d1f3d;
        color: #c084fc;
    }
}

/* Progress Indicator Mobile */
@media (max-width: 600px) {
    .progress-details {
        flex-direction: column;
        gap: 0.25rem;
    }
}

#sortable-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-left: 0;
}

#sortable-list li {
    width: 40%;
    margin: 8px auto;
    display: block;
    padding: 8px 12px;
    margin-bottom: 4px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    cursor: grab;
    transition: transform 0.2s ease-in-out;
}

#sortable-list li:hover {
    /* Less bright hover color */
    background-color: #e0e0e0;
}

#sortable-list li:active {
    /* Active style from demo-list */
    opacity: 0.8;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.button-container {
    display: flex;
    justify-content: center;
    margin-top: 1.5rem;
}

.compare-button {
    background-color: #4a6bdf;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.75rem 2rem;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

.compare-button:hover {
    background-color: #3a5bcf;
}

.compare-button:active {
    background-color: #2a4bbf;
}

/* Add disabled state styling for compare button loading/submitting state */
.compare-button:disabled {
    opacity: 0.6;
    cursor: wait;
}

.no-batch-message {
    text-align: center;
    padding: 2rem;
    color: #666;
    font-style: italic;
}

/* Sortable item animation */
.sortable-ghost {
    opacity: 0.4;
    background-color: #e0e0e0 !important;
}

@media (prefers-color-scheme: dark) {
    #sortable-list li {
        background-color: var(--bg-surface);
        border: 1px solid var(--border-subtle);
        color: var(--text-primary);
    }

    #sortable-list li:hover {
        background-color: var(--bg-elevated);
        border-color: var(--border-default);
    }

    #sortable-list li:active {
        background-color: var(--bg-hover);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    }

    .sortable-ghost {
        opacity: 0.5;
        background-color: var(--bg-hover) !important;
        border-color: var(--accent-primary) !important;
    }

    .compare-button {
        background-color: var(--accent-primary);
    }

    .compare-button:hover {
        background-color: #6366f1;
    }

    .compare-button:active {
        background-color: #4f46e5;
    }

    .no-batch-message {
        color: var(--text-muted);
    }
}

/* Mobile responsiveness */
@media (max-width: 600px) {

    #demo-list li,
    #sortable-list li {
        width: 90% !important;
        margin: 8px auto;
    }

    .compare-button {
        width: 90% !important;
        margin: 0.5rem auto;
        display: block;
    }
}

/* Share Page Styles */
.share-main {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
}

.ranked-items {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.ranked-items li {
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    transition: background 0.2s;
}

.ranked-items li:hover {
    background: #e9ecef;
}

.rank-number {
    font-weight: bold;
    margin-right: 0.75rem;
    color: #4a6bdf;
    min-width: 2rem;
    display: inline-block;
    text-align: right;
}

.batch-count {
    background: #f5f7fa;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 500;
    color: #333;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    display: inline-block;
}

.batch-count-label {
    color: #4a6bdf;
    font-weight: 600;
    margin-right: 0.5rem;
}

.batch-count-value {
    font-family: monospace;
    font-size: 1.2em;
}

/* Share Page Dark Mode */
@media (prefers-color-scheme: dark) {
    .ranked-items li {
        background: var(--bg-surface);
        border-color: var(--border-subtle);
        color: var(--text-primary);
    }

    .ranked-items li:hover {
        background: var(--bg-elevated);
        border-color: var(--border-default);
    }

    .rank-number {
        color: var(--accent-link);
        text-shadow: none;
    }

    .batch-count {
        background: var(--bg-elevated);
        color: var(--text-primary);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }

    .batch-count-label {
        color: var(--accent-link);
    }

    .batch-count-value {
        color: var(--text-primary);
    }

    .share-link-button {
        background: var(--accent-primary);
    }

    .share-link-button:hover {
        background: #6366f1;
    }

    .rerank-button {
        background: var(--bg-elevated);
        border: 1px solid var(--border-default);
    }

    .rerank-button:hover {
        background: var(--bg-hover);
    }

    .share-link-url code {
        background: var(--bg-elevated);
        color: var(--text-secondary);
        padding: 0.5rem 1rem;
        border-radius: 4px;
        display: inline-block;
    }

    /* Flash messages in dark mode */
    .notice {
        background: #1a3329;
        color: #34d399;
        border-color: #22543d;
    }

    .alert {
        background: #3d1f1f;
        color: #f87171;
        border-color: #7f1d1d;
    }
}

/* Form Styles (Devise and general forms) */

/* Auth form container */
.auth-form {
    max-width: 400px;
    margin: 0 auto;
    padding: 1rem;
}

.auth-form h2 {
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-form h3,
.auth-form h4 {
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

/* Auth links section */
.auth-links {
    margin-top: 1.5rem;
    text-align: center;
}

.auth-links a {
    display: block;
    margin: 0.5rem 0;
}

.field {
    margin-bottom: 1rem;
}

.field label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.field input[type="email"],
.field input[type="password"],
.field input[type="text"],
.field textarea {
    width: 100%;
    max-width: 320px;
    padding: 0.6rem 0.8rem;
    font-size: 1rem;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #fff;
    color: #222;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus,
.field textarea:focus {
    outline: none;
    border-color: #4a6bdf;
    box-shadow: 0 0 0 3px rgba(74, 107, 223, 0.15);
}

.actions {
    margin-top: 1.5rem;
}

.actions input[type="submit"] {
    background: #4a6bdf;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0.6rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.actions input[type="submit"]:hover {
    background: #3a5bcf;
    transform: translateY(-1px);
}

.actions input[type="submit"]:active {
    background: #2a4bbf;
    transform: translateY(0);
}

/* Form Dark Mode */
@media (prefers-color-scheme: dark) {
    .field label {
        color: var(--text-primary);
    }

    .field input[type="email"],
    .field input[type="password"],
    .field input[type="text"],
    .field textarea {
        background: var(--bg-surface);
        border-color: var(--border-default);
        color: var(--text-primary);
    }

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

    .field input:focus,
    .field textarea:focus {
        border-color: var(--accent-primary);
        box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2);
    }

    .actions input[type="submit"] {
        background: var(--accent-primary);
    }

    .actions input[type="submit"]:hover {
        background: #6366f1;
    }

    .actions input[type="submit"]:active {
        background: #4f46e5;
    }

    /* Checkbox styling */
    .field input[type="checkbox"] {
        accent-color: var(--accent-primary);
    }
}

/* Error Page Styles */
.error-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 2rem;
    text-align: center;
}

.error-content {
    max-width: 400px;
}

.error-code {
    font-size: 6rem;
    font-weight: 800;
    line-height: 1;
    margin: 0 0 0.5rem 0;
}

.error-404 {
    color: #ef4444;
}

.error-500 {
    color: #ef4444;
}

.error-422 {
    color: #f59e0b;
}

.error-page h2 {
    font-size: 1.5rem;
    margin: 0.5rem 0;
}

.error-page p {
    color: #666;
    margin: 0.5rem 0;
}

.error-actions {
    margin-top: 1.5rem;
}

.error-button {
    display: inline-block;
    background: #ef4444;
    color: #fff;
    padding: 0.6rem 1.5rem;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.error-button:hover {
    background: #dc2626;
    color: #fff;
}

.error-button-secondary {
    background: #6b7280;
}

.error-button-secondary:hover {
    background: #4b5563;
}

.error-support {
    font-size: 0.85rem;
    color: #999;
    margin-top: 1rem;
}

/* Error Page Dark Mode */
@media (prefers-color-scheme: dark) {
    .error-page h2 {
        color: var(--text-primary);
    }

    .error-page p {
        color: var(--text-secondary);
    }

    .error-404,
    .error-500 {
        color: #f87171;
    }

    .error-422 {
        color: #fbbf24;
    }

    .error-button {
        background: #f87171;
    }

    .error-button:hover {
        background: #ef4444;
    }

    .error-button-secondary {
        background: var(--bg-elevated);
        border: 1px solid var(--border-default);
        color: var(--text-primary);
    }

    .error-button-secondary:hover {
        background: var(--bg-hover);
    }

    .error-support {
        color: var(--text-muted);
    }
}

/* List Picker Page Styles */
.picker-subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 2rem;
}

.existing-list-notice {
    text-align: center;
    background: #fff3cd;
    color: #856404;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    max-width: 400px;
    width: 100%;
    font-size: 0.9rem;
}

.ranking-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 400px;
    width: 100%;
    padding: 0 1rem;
}

.option-card-form {
    width: 100%;
}

.option-card {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.option-card:hover {
    border-color: #4a6bdf;
    background: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 107, 223, 0.15);
}

.option-card:active {
    transform: translateY(0);
}

.option-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.option-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #222;
    margin-bottom: 0.5rem;
}

.option-description {
    font-size: 0.9rem;
    color: #666;
}

.picker-footer {
    text-align: center;
    margin-top: 2rem;
    padding: 0 1rem;
    color: #666;
    font-size: 0.9rem;
}

.picker-footer strong {
    color: #4a6bdf;
}

/* List Picker Dark Mode */
@media (prefers-color-scheme: dark) {
    .picker-subtitle {
        color: var(--text-secondary);
    }

    .existing-list-notice {
        background: #3d3200;
        color: #ffc107;
    }

    .option-card {
        background: var(--bg-surface);
        border-color: var(--border-subtle);
    }

    .option-card:hover {
        background: var(--bg-elevated);
        border-color: var(--accent-primary);
        box-shadow: 0 4px 12px rgba(129, 140, 248, 0.2);
    }

    .option-title {
        color: var(--text-primary);
    }

    .option-description {
        color: var(--text-secondary);
    }

    .picker-footer {
        color: var(--text-secondary);
    }

    .picker-footer strong {
        color: var(--accent-link);
    }
}