/* NextBook Web Interface Styles */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #64748b;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --radius-lg: 12px;
}

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

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

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}

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

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

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 500;
}

/* Tab Content */
.tab-content {
    display: none;
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

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

.tab-content h2 {
    margin-bottom: 0.5rem;
    color: var(--text);
}

.tab-content > p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* Book Entry Form */
.book-entry {
    display: grid;
    grid-template-columns: 2fr 1.5fr 100px 1.5fr 40px;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    align-items: center;
}

.book-entry input,
.book-entry select {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    transition: border-color 0.2s ease;
}

.book-entry input:focus,
.book-entry select:focus {
    outline: none;
    border-color: var(--primary);
}

.remove-book {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--danger);
    color: white;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 1.2rem;
    transition: opacity 0.2s ease;
}

.remove-book:hover {
    opacity: 0.8;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: var(--primary);
    color: white;
    margin-top: 1.5rem;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:disabled {
    background: var(--secondary);
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-secondary {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

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

#add-book {
    margin-top: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* File Upload */
.file-upload {
    margin: 1.5rem 0;
}

.file-upload input[type="file"] {
    display: none;
}

.file-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
}

.file-label:hover,
.file-label.drag-over {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

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

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

.file-selected {
    margin-top: 0.75rem;
    color: var(--success);
    font-weight: 500;
}

/* Options */
.option-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

.option-row label {
    color: var(--text-muted);
}

.option-row select {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* Instructions */
.instructions {
    background: var(--background);
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.instructions h3 {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.instructions ol {
    padding-left: 1.25rem;
    color: var(--text-muted);
}

.instructions li {
    margin-bottom: 0.25rem;
}

.instructions a {
    color: var(--primary);
}

/* Demo Books */
.demo-books {
    background: var(--background);
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
}

.demo-books h3 {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
}

.demo-books ul {
    list-style: none;
}

.demo-books li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
}

.demo-books li:last-child {
    border-bottom: none;
}

.demo-books strong {
    color: var(--text);
}

/* Loading State */
#loading {
    text-align: center;
    padding: 3rem;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.loading-content h2 {
    margin-bottom: 0.5rem;
}

.loading-phase {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

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

.agent-status {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.agent {
    padding: 0.5rem 1rem;
    background: var(--background);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: all 0.3s ease;
}

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

.agent.debating {
    animation: pulse 0.5s ease-in-out infinite alternate;
}

.agent.synthesizing {
    background: var(--success);
    color: white;
}

@keyframes pulse {
    from { transform: scale(1); }
    to { transform: scale(1.05); }
}

/* Results */
#results {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

#results h2 {
    text-align: center;
    margin-bottom: 2rem;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat {
    text-align: center;
    padding: 1rem;
    background: var(--background);
    border-radius: var(--radius);
}

.stat-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Recommendation Cards */
.recommendation {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: box-shadow 0.2s ease;
}

.recommendation:hover {
    box-shadow: var(--shadow-lg);
}

.rec-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.rec-position {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-weight: 700;
    flex-shrink: 0;
}

.rec-title-section {
    flex: 1;
}

.rec-title {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.rec-author {
    color: var(--text-muted);
}

.trust-factor {
    text-align: center;
    padding: 0.5rem 1rem;
    background: var(--background);
    border-radius: var(--radius);
}

.trust-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--success);
}

.trust-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.rec-cover {
    max-width: 120px;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.rec-meta {
    display: flex;
    gap: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.rec-why {
    background: var(--background);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.rec-why h4 {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rec-connections {
    margin-bottom: 1rem;
}

.rec-connections h4 {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.connection {
    padding: 0.75rem;
    background: var(--background);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.connection-type {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: var(--primary-light);
    color: white;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-right: 0.5rem;
    text-transform: uppercase;
}

.rec-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.agents {
    text-align: right;
}

#start-over {
    display: block;
    width: 100%;
    margin-top: 2rem;
}

/* Error State */
#error {
    background: var(--surface);
    padding: 3rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    text-align: center;
}

.error-content h2 {
    color: var(--danger);
    margin-bottom: 1rem;
}

#error-message {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* Hidden */
.hidden {
    display: none !important;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 3rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

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

    header h1 {
        font-size: 2rem;
    }

    .book-entry {
        grid-template-columns: 1fr;
    }

    .book-entry .remove-book {
        justify-self: end;
    }

    .tabs {
        overflow-x: auto;
    }

    .tab {
        white-space: nowrap;
        padding: 0.5rem 1rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .rec-header {
        flex-wrap: wrap;
    }

    .trust-factor {
        width: 100%;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .trust-value {
        font-size: 1.25rem;
    }

    .rec-footer {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }

    .agents {
        text-align: left;
    }
}
