/* ============================================================
   Redefined Spines App — Warm Bookish Theme Override
   Transforms the dark tech theme into the warm cream/brown/gold
   palette that matches the landing page.
   ============================================================ */

/* ===== Override CSS Custom Properties ===== */
:root {
    /* Surface colors — warm layered depth */
    --bg-base: #F5F0E8;
    --bg-card: rgba(255, 252, 247, 0.9);
    --bg-card-solid: #FEFCF8;
    --bg-elevated: #FFF9F0;
    --bg-input: #FFFFFF;
    --bg-hover: #F0EAE0;

    /* Borders — warm tones */
    --border-subtle: rgba(44, 24, 16, 0.08);
    --border-default: rgba(44, 24, 16, 0.12);
    --border-strong: rgba(44, 24, 16, 0.2);

    /* Primary accent — warm brown/burgundy */
    --accent: #2C1810;
    --accent-hover: #3D2B1F;
    --accent-muted: rgba(44, 24, 16, 0.08);
    --accent-glow: rgba(197, 165, 90, 0.25);

    /* Secondary accents — warm palette */
    --green: #5A8C5A;
    --green-muted: rgba(90, 140, 90, 0.1);
    --amber: #B8860B;
    --red: #A0522D;
    --blue: #5B7BA0;

    /* Text hierarchy — dark warm */
    --text-primary: #1A1410;
    --text-secondary: #5C4E42;
    --text-tertiary: #8B7D70;

    /* Shadows — warm */
    --shadow-sm: 0 1px 3px rgba(44, 24, 16, 0.06), 0 1px 2px rgba(44, 24, 16, 0.04);
    --shadow-md: 0 4px 12px rgba(44, 24, 16, 0.08), 0 2px 4px rgba(44, 24, 16, 0.04);
    --shadow-lg: 0 8px 30px rgba(44, 24, 16, 0.1), 0 4px 12px rgba(44, 24, 16, 0.06);
    --shadow-xl: 0 20px 50px rgba(44, 24, 16, 0.12), 0 8px 20px rgba(44, 24, 16, 0.08);
}

/* ===== Typography upgrade ===== */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-base);
    color: var(--text-secondary);
}

/* Subtle warm texture instead of indigo glow */
body::before {
    background: radial-gradient(ellipse at 50% 0%, rgba(197, 165, 90, 0.06) 0%, transparent 60%);
}

/* ===== Header — warm branding ===== */
.app-header {
    border-bottom: 1px solid rgba(197, 165, 90, 0.2);
    padding: 24px 0;
}

.app-header .logo {
    background: linear-gradient(135deg, #2C1810, #5C4033);
    box-shadow: 0 4px 14px rgba(44, 24, 16, 0.2);
    border-radius: 8px;
}

.app-header .brand {
    font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
    background: linear-gradient(135deg, #2C1810, #5C4033);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.8rem;
    letter-spacing: -0.5px;
}

.app-header .tagline {
    color: var(--text-tertiary);
    letter-spacing: 1.5px;
}

/* ===== Headings — serif ===== */
h1, h2 {
    font-family: 'Playfair Display', Georgia, serif;
    color: var(--text-primary);
}

/* ===== Library Section ===== */
.library-section {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-sm);
}

.library-count {
    background: rgba(197, 165, 90, 0.15);
    color: #8B6914;
}

/* ===== Library Action Buttons ===== */
.library-actions button {
    border: 1px solid var(--border-default);
    background: transparent;
    color: var(--text-secondary);
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.library-actions button:hover {
    background: rgba(44, 24, 16, 0.05);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

/* ===== Library Cards ===== */
.library-card {
    background: #FFFFFF;
    border: 1px solid var(--border-subtle);
    border-left: 3px solid transparent;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.library-card:hover {
    background: #FFFBF5;
    box-shadow: var(--shadow-md);
    transform: translateX(3px);
}

.library-card[data-status="reading"] {
    border-left-color: var(--amber);
}

.library-card[data-status="finished"] {
    border-left-color: var(--green);
}

.library-card[data-status="want-to-read"] {
    border-left-color: var(--blue);
}

.library-card .book-cover {
    background: #E8E0D4;
    border-radius: 4px;
    box-shadow: 1px 1px 4px rgba(44, 24, 16, 0.12);
}

.library-card .spine-color-dot {
    border: 2px solid rgba(44, 24, 16, 0.12);
}

/* ===== Reading Status Badges — warm tones ===== */
.reading-status-badge {
    font-weight: 600;
    letter-spacing: 0.5px;
}

.reading-status-badge.want-to-read {
    background: rgba(91, 123, 160, 0.1);
    color: #4A6A8A;
    border: 1px solid rgba(91, 123, 160, 0.2);
}

.reading-status-badge.reading {
    background: rgba(184, 134, 11, 0.1);
    color: #8B6914;
    border: 1px solid rgba(184, 134, 11, 0.2);
}

.reading-status-badge.finished {
    background: rgba(90, 140, 90, 0.1);
    color: #3D6B3D;
    border: 1px solid rgba(90, 140, 90, 0.2);
}

/* ===== Filter/Sort Dropdowns ===== */
.library-filter select,
.filter-controls select {
    background: #FFFFFF;
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    border-radius: 6px;
}

.library-filter select:focus,
.filter-controls select:focus {
    border-color: #C5A55A;
    box-shadow: 0 0 0 3px rgba(197, 165, 90, 0.15);
}

/* ===== Search Section ===== */
#search-input {
    background: #FFFFFF;
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    border-radius: 8px;
}

#search-input:focus {
    border-color: #C5A55A;
    box-shadow: 0 0 0 3px rgba(197, 165, 90, 0.2);
    background: #FFFFFF;
}

#search-input::placeholder {
    color: var(--text-tertiary);
}

#search-btn {
    background: #2C1810;
    color: #FBF7F0;
    border-radius: 8px;
    font-weight: 600;
}

#search-btn:hover {
    background: #722F37;
    box-shadow: 0 4px 14px rgba(44, 24, 16, 0.2);
}

#search-btn:disabled {
    background: #E8E0D4;
    color: var(--text-tertiary);
}

/* ===== Search Result Book Cards ===== */
.book-card {
    background: #FFFFFF;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
}

.book-card:hover {
    background: #FFFBF5;
    border-color: var(--border-default);
    box-shadow: var(--shadow-md);
}

.book-card.in-library {
    border-color: rgba(90, 140, 90, 0.25);
    background: rgba(90, 140, 90, 0.04);
    border-left: 3px solid var(--green);
}

.book-cover {
    background: #E8E0D4;
    border-radius: 5px;
}

.book-action {
    color: var(--green);
}

.library-card .book-action {
    color: var(--red);
}

/* ===== Sync / Spine Display Section ===== */
.sync-section {
    background: linear-gradient(135deg, rgba(197, 165, 90, 0.06) 0%, var(--bg-card) 100%);
    border: 1px solid rgba(197, 165, 90, 0.2);
    box-shadow: var(--shadow-sm);
}

.sync-header h2 {
    color: #8B6914;
}

.sync-status {
    background: rgba(44, 24, 16, 0.03);
    border: 1px solid var(--border-subtle);
    color: var(--text-tertiary);
}

.sync-status.connected {
    background: rgba(90, 140, 90, 0.1);
    border-color: rgba(90, 140, 90, 0.2);
    color: var(--green);
}

.sync-btn-primary {
    background: #2C1810 !important;
    color: #FBF7F0 !important;
}

.sync-btn-primary:hover {
    background: #722F37 !important;
    box-shadow: 0 4px 14px rgba(44, 24, 16, 0.2) !important;
}

.sync-btn-secondary {
    background: transparent !important;
    border: 1px solid var(--border-default) !important;
    color: var(--text-secondary) !important;
}

.sync-btn-secondary:hover {
    background: rgba(44, 24, 16, 0.04) !important;
    border-color: var(--border-strong) !important;
}

/* ===== Modals — warm overlay ===== */
.modal-overlay {
    background: rgba(26, 20, 16, 0.6);
}

.modal {
    background: #FEFCF8;
    border: 1px solid var(--border-default);
    box-shadow: var(--shadow-xl);
}

.modal-header {
    background: linear-gradient(180deg, rgba(197, 165, 90, 0.08) 0%, transparent 100%);
}

.modal-close {
    background: rgba(44, 24, 16, 0.06);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
}

.modal-close:hover {
    background: rgba(44, 24, 16, 0.12);
    color: var(--text-primary);
}

.modal-cover {
    box-shadow: 0 12px 32px rgba(44, 24, 16, 0.15);
}

/* ===== Modal buttons ===== */
.modal-actions .btn,
.btn-add-to-library,
.btn-save,
.btn-confirm {
    border-radius: 8px;
}

/* ===== Sync modal fields ===== */
.sync-field input,
.sync-field select {
    background: #FFFFFF;
    border: 1px solid var(--border-default);
    color: var(--text-primary);
}

.sync-field input:focus,
.sync-field select:focus {
    border-color: #C5A55A;
    box-shadow: 0 0 0 3px rgba(197, 165, 90, 0.15);
}

/* ===== Spine Preview ===== */
.sync-preview {
    background: #F0EAE0;
    border: 1px solid var(--border-subtle);
}

/* ===== Spinner ===== */
.spinner {
    border: 2px solid rgba(44, 24, 16, 0.08);
    border-top-color: #C5A55A;
}

/* ===== Empty States ===== */
.empty-state-title {
    font-family: 'Playfair Display', Georgia, serif;
    color: var(--text-primary);
}

.empty-library {
    color: var(--text-tertiary);
}

/* ===== Google Books Connect Section ===== */
.gb-section {
    background: linear-gradient(135deg, rgba(66, 133, 244, 0.04) 0%, rgba(255, 252, 247, 0.9) 100%);
    border: 1px solid rgba(66, 133, 244, 0.15);
    border-radius: 10px;
    padding: 18px;
    margin-bottom: 16px;
}

.gb-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.gb-icon {
    font-size: 20px;
}

.gb-title {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.gb-badge {
    margin-left: auto;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 10px;
    background: rgba(66, 133, 244, 0.1);
    color: #4285F4;
}

.gb-desc {
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.5;
    margin-bottom: 14px;
}

.gb-connect-btn {
    width: 100%;
    padding: 12px 20px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    background: #4285F4;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.gb-connect-btn:hover {
    background: #3367D6;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(66, 133, 244, 0.3);
}

.gb-connect-btn:disabled {
    background: #E8E0D4;
    color: var(--text-tertiary);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.gb-google-icon {
    width: 22px;
    height: 22px;
    background: #fff;
    color: #4285F4;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.gb-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.gb-progress {
    margin-top: 12px;
}

.gb-progress-track {
    height: 6px;
    background: rgba(66, 133, 244, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.gb-progress-bar {
    height: 100%;
    background: #4285F4;
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
}

.gb-progress-text {
    font-size: 11px;
    color: var(--text-tertiary);
    display: block;
    margin-top: 6px;
    text-align: center;
}

.gb-status {
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.4;
}

.gb-status-loading {
    background: rgba(66, 133, 244, 0.08);
    color: #4285F4;
}

.gb-status-success {
    background: rgba(90, 140, 90, 0.08);
    color: #3D6B3D;
}

.gb-status-error {
    background: rgba(160, 82, 45, 0.08);
    color: #A0522D;
}

.gb-status-info {
    background: rgba(44, 24, 16, 0.04);
    color: var(--text-secondary);
}

.gb-divider {
    text-align: center;
    color: var(--text-tertiary);
    font-size: 12px;
    margin: 16px 0;
    position: relative;
}

.gb-divider::before,
.gb-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 35%;
    height: 1px;
    background: var(--border-subtle);
}

.gb-divider::before { left: 0; }
.gb-divider::after { right: 0; }

/* ===== Audible Import Section ===== */
.audible-section {
    background: linear-gradient(135deg, rgba(255, 153, 0, 0.04) 0%, rgba(255, 252, 247, 0.9) 100%);
    border: 1px solid rgba(255, 153, 0, 0.15);
    border-radius: 10px;
    padding: 18px;
    margin-bottom: 16px;
}

.audible-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.audible-icon { font-size: 20px; }

.audible-title {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.audible-badge {
    margin-left: auto;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 10px;
    background: rgba(255, 153, 0, 0.1);
    color: #F59E0B;
}

.audible-desc {
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.5;
    margin-bottom: 14px;
}

.audible-steps {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.audible-step {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: rgba(255, 252, 247, 0.6);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 12px;
}

.audible-step-num {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #F59E0B;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.audible-step-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.audible-step-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.audible-step-hint {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* The draggable bookmarklet button */
.audible-bookmarklet-btn {
    display: inline-block;
    padding: 8px 16px;
    background: linear-gradient(135deg, #F59E0B, #D97706);
    color: #fff !important;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none !important;
    cursor: grab;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.25);
    user-select: none;
    align-self: flex-start;
}

.audible-bookmarklet-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
}

.audible-bookmarklet-btn:active {
    cursor: grabbing;
}

.audible-open-btn {
    display: inline-block;
    padding: 8px 16px;
    background: var(--bg-card-solid);
    color: var(--text-primary) !important;
    border: 1px solid var(--border-default);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none !important;
    transition: all 0.2s ease;
    align-self: flex-start;
}

.audible-open-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
}

/* Auto-import banner that shows when books arrive via bookmarklet */
.audible-auto-import-banner {
    background: linear-gradient(135deg, rgba(90, 140, 90, 0.08) 0%, rgba(255, 252, 247, 0.95) 100%);
    border: 1px solid rgba(90, 140, 90, 0.2);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
}

.audible-auto-import-banner h3 {
    font-family: 'Playfair Display', serif;
    font-size: 16px;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

.audible-auto-import-banner p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

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

/* ===== Toast / Notification ===== */
.toast {
    background: #2C1810;
    color: #FBF7F0;
    border: 1px solid rgba(197, 165, 90, 0.3);
}

/* ===== Scrollbar — warm ===== */
::-webkit-scrollbar {
    width: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(44, 24, 16, 0.15);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(44, 24, 16, 0.25);
}

/* ===== Selection color ===== */
::selection {
    background: rgba(197, 165, 90, 0.3);
    color: #1A1410;
}

/* (Old Audible inline style overrides removed — now using .audible-* classes) */

#import-progress div[style*="background: #333"] {
    background: var(--border-subtle) !important;
}

#import-progress div[style*="background: #6366f1"] {
    background: #C5A55A !important;
}

#import-progress p {
    color: var(--text-tertiary) !important;
}

/* Modal titles and actions in warm theme */
.modal-title {
    font-family: 'Playfair Display', Georgia, serif;
    color: var(--text-primary);
}

.modal-btn-primary {
    background: #2C1810 !important;
    color: #FBF7F0 !important;
    border: none !important;
    border-radius: 8px !important;
}

.modal-btn-primary:hover {
    background: #722F37 !important;
}

.import-tab-bar button,
.import-btn {
    border-radius: 6px;
}

.import-tab-bar button.active {
    background: #2C1810;
    color: #FBF7F0;
}

/* ===== Share/Export modals ===== */
textarea {
    background: #FFFFFF;
    border: 1px solid var(--border-default);
    color: var(--text-primary);
}

textarea:focus {
    border-color: #C5A55A;
    box-shadow: 0 0 0 3px rgba(197, 165, 90, 0.15);
}
