/**
 * Mijn Bijbel - Component Styles
 * Buttons, Forms, Cards, etc.
 */

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    cursor: pointer;
}

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

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

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

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

.btn-ghost {
    background-color: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background-color: var(--bg-tertiary);
}

.btn-full {
    width: 100%;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
}

/* ==========================================================================
   Form Elements
   ========================================================================== */

.input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-family: var(--font-body);
    font-size: var(--text-base);
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input:focus,
input:focus,
textarea:focus {
    border-color: var(--brand-color);
    outline: none;
}

/* Remove focus ring from search inputs */
.search-input:focus,
input[type="search"]:focus,
.tab-reference-input:focus {
    border-color: var(--border-color);
    box-shadow: none;
    outline: none;
}

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

/* Search Input */
.search-input-group {
    position: relative;
    display: flex;
    gap: var(--space-2);
    align-items: center;
}

.search-icon {
    position: absolute;
    right: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    flex: 1;
    padding-left: var(--space-4);
    padding-right: calc(var(--space-4) + 24px + var(--space-2));
}

.search-button {
    background: var(--brand-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    min-width: 48px;
    height: 48px;
}

.search-button:hover {
    background: var(--brand-dark);
}

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

.search-button .material-symbols-outlined {
    font-size: 24px;
}

/* Toggle Switch */
.toggle-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) 0;
    cursor: pointer;
}

.toggle-option input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    width: 48px;
    height: 28px;
    background-color: var(--border-color);
    border-radius: var(--radius-full);
    position: relative;
    transition: background-color var(--transition-fast);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 4px;
    width: 20px;
    height: 20px;
    background-color: white;
    border-radius: var(--radius-full);
    transition: transform var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.toggle-option input:checked + .toggle-slider {
    background-color: var(--brand-color);
}

.toggle-option input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* Range Slider */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: var(--border-color);
    border-radius: var(--radius-full);
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--brand-color);
    border-radius: var(--radius-full);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--brand-color);
    border-radius: var(--radius-full);
    cursor: pointer;
    border: none;
}

/* ==========================================================================
   Bible Verses
   ========================================================================== */

.verse {
    margin-bottom: var(--space-2);
}

.verse-number {
    display: inline;
    font-size: 0.7em;
    font-weight: 600;
    color: var(--brand-color);
    vertical-align: super;
    margin-right: var(--space-1);
    user-select: none;
}

.verse-text {
    display: inline;
}

/* Verse Lines Mode */
.verse-lines .verse {
    display: block;
    margin-bottom: var(--space-3);
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--divider-color);
}

.verse-lines .verse:last-child {
    border-bottom: none;
}

/* Poetry Mode */
.poetry-mode .verse {
    display: block;
    padding-left: var(--space-8);
    text-indent: calc(var(--space-6) * -1);
    margin-bottom: var(--space-2);
    line-height: 1.9;
}

.poetry-mode .verse-number {
    margin-right: var(--space-2);
}

/* Highlighted Verses */
.verse.highlighted-green {
    background-color: var(--highlight-green);
    padding: var(--space-1) var(--space-2);
    margin: 0 calc(var(--space-2) * -1);
    border-radius: var(--radius-sm);
}

.verse.highlighted-gold {
    background-color: var(--highlight-gold);
    padding: var(--space-1) var(--space-2);
    margin: 0 calc(var(--space-2) * -1);
    border-radius: var(--radius-sm);
}

/* Verse Selection */
.verse-selectable {
    cursor: text;
    transition: background-color var(--transition-fast);
    border-radius: var(--radius-sm);
    padding: var(--space-1) var(--space-2);
    margin: 0 calc(var(--space-1) * -1);
    user-select: text;
    -webkit-user-select: text;
}

/* Highlight on selection (native browser selection) */
.verse-selectable::selection {
    background-color: var(--brand-light);
}

.verse-selectable:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.theme-dark .verse-selectable:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.verse-selected {
    background-color: var(--brand-light) !important;
    border-radius: var(--radius-sm);
}

/* Verse Action Bar */
.verse-action-bar {
    position: fixed;
    bottom: calc(var(--bottom-nav-height, 0px) + var(--safe-area-bottom, 0px) + var(--space-4));
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-xl);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
    z-index: var(--z-popover);
}

.verse-action-bar.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
}

.action-bar-count {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    padding: 0 var(--space-2);
    border-right: 1px solid var(--border-color);
    margin-right: var(--space-1);
}

.action-bar-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.action-bar-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.action-bar-btn:active {
    transform: scale(0.95);
}

/* Toast Notification */
.toast-notification {
    position: fixed;
    bottom: calc(var(--bottom-nav-height, 0px) + var(--safe-area-bottom, 0px) + 100px);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: var(--space-3) var(--space-4);
    background-color: var(--text-primary);
    color: var(--bg-secondary);
    font-size: var(--text-sm);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
    z-index: var(--z-tooltip);
}

.toast-notification.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
}

/* ==========================================================================
   Bottom Sheet
   ========================================================================== */

.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100vw;
    max-height: 80vh;
    background-color: var(--bg-secondary);
    border-radius: 0;
    box-shadow: var(--shadow-xl);
    transform: translateY(100%);
    transition: transform 300ms var(--ease-out);
    z-index: var(--z-modal);
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.bottom-sheet.active {
    transform: translateY(0);
}

.bottom-sheet-full {
    max-height: 90vh;
}

.sheet-handle {
    width: 40px;
    height: 4px;
    background-color: var(--border-color);
    border-radius: var(--radius-full);
    margin: var(--space-3) auto;
    flex-shrink: 0;
}

.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) var(--space-4) var(--space-3);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.sheet-title {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: 600;
}

.sheet-close {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    color: var(--text-muted);
    transition: background-color var(--transition-fast);
}

.sheet-close:hover {
    background-color: var(--bg-tertiary);
}

.sheet-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
    padding-bottom: calc(var(--space-4) + var(--safe-area-bottom));
}

.sheet-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
    z-index: calc(var(--z-modal) - 1);
}

.sheet-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* ==========================================================================
   Settings
   ========================================================================== */

.settings-section {
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--border-color);
}

.settings-section:last-child {
    border-bottom: none;
}

.settings-label {
    font-family: var(--font-display);
    font-size: var(--text-base);
    font-weight: 600;
    margin-bottom: var(--space-3);
    color: var(--text-primary);
}

/* Theme Options */
.theme-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-2);
}

.theme-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-4);
    background-color: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.theme-btn:hover {
    border-color: var(--text-muted);
}

.theme-btn.active {
    background-color: var(--brand-light);
    border-color: var(--brand-color);
    color: var(--brand-color);
}

/* Font Size Slider */
.font-size-slider {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.font-size-label {
    font-family: var(--font-body);
    color: var(--text-muted);
}

.font-size-label.small {
    font-size: var(--text-sm);
}

.font-size-label.large {
    font-size: var(--text-xl);
}

/* Settings Hint */
.settings-hint {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-bottom: var(--space-2);
}

/* API Key Input */
.api-key-input-group {
    display: flex;
    gap: var(--space-2);
}

.api-key-input {
    flex: 1;
    padding: var(--space-3);
    font-family: monospace;
    font-size: var(--text-sm);
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
}

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

.api-key-toggle {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-muted);
}

.api-key-toggle:hover {
    background-color: var(--bg-primary);
}

/* ==========================================================================
   Search Filters
   ========================================================================== */

.search-filters {
    display: flex;
    gap: var(--space-2);
    margin: var(--space-4) 0;
}

.filter-btn {
    padding: var(--space-2) var(--space-4);
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.filter-btn:hover {
    border-color: var(--text-muted);
}

.filter-btn.active {
    background-color: var(--brand-color);
    border-color: var(--brand-color);
    color: white;
}

/* Search Mode Indicator */
.search-mode-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    margin: var(--space-2) 0;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.search-mode-indicator .material-symbols-outlined {
    font-size: 18px;
}

.search-mode-indicator.ai-enabled {
    background-color: var(--brand-light);
    color: var(--brand-color);
}

.search-mode-indicator.ai-enabled .material-symbols-outlined {
    color: var(--brand-color);
}

/* Search Results */
.search-results {
    margin-top: var(--space-4);
}

/* ==========================================================================
   Connections (Cross-References)
   ========================================================================== */

.connections-source {
    padding: var(--space-4);
    margin-bottom: var(--space-4);
    background-color: var(--brand-light);
    border-radius: var(--radius-md);
}

.connections-source-ref {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--brand-color);
    margin-bottom: var(--space-2);
}

.connections-source-text {
    font-family: var(--font-body);
    font-size: var(--text-base);
    color: var(--text-primary);
    line-height: 1.7;
}

.connections-results {
    display: flex;
    flex-direction: column;
}

.connection-type {
    font-size: var(--text-xs);
    color: var(--brand-color);
    background-color: var(--brand-light);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.search-result {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.search-result:hover {
    background-color: var(--bg-tertiary);
}

.search-result:active {
    background-color: var(--brand-light);
}

.search-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-2);
}

.search-result-ref {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--brand-color);
}

.search-result-text {
    font-size: var(--text-base);
    color: var(--text-secondary);
    line-height: 1.7;
    font-family: var(--font-body);
}

.verse-num-highlight {
    font-size: 0.75em;
    font-weight: 600;
    color: var(--brand-color);
    vertical-align: super;
}

.search-result-loading {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--brand-color);
    border-radius: var(--radius-full);
    animation: spin 1s linear infinite;
}

/* ==========================================================================
   Studies List
   ========================================================================== */

.studies-list {
    margin-top: var(--space-4);
}

.study-card {
    padding: var(--space-4);
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-3);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.study-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.study-card-title {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: 600;
    margin-bottom: var(--space-1);
}

.study-card-subtitle {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-bottom: var(--space-2);
}

.study-card-meta {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: var(--space-8);
    color: var(--text-muted);
}

.empty-state .material-symbols-outlined {
    font-size: 48px;
    margin-bottom: var(--space-4);
    opacity: 0.5;
}

/* ==========================================================================
   Presentation Mode
   ========================================================================== */

.presentation-overlay {
    position: fixed;
    inset: 0;
    background-color: var(--bg-primary);
    z-index: var(--z-modal);
    display: none;
    flex-direction: column;
}

.presentation-overlay.active {
    display: flex;
}

.presentation-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-8);
    display: flex;
    align-items: center;
    justify-content: center;
}

.presentation-content .verse {
    font-size: var(--text-2xl);
    line-height: 1.8;
}

.presentation-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    padding: var(--space-4);
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.presentation-nav-btn {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.presentation-nav-btn:hover {
    background-color: var(--brand-color);
    color: white;
}

.presentation-dots {
    display: flex;
    gap: var(--space-2);
}

.presentation-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
    background-color: var(--border-color);
    transition: background-color var(--transition-fast);
}

.presentation-dot.active {
    background-color: var(--brand-color);
}

.presentation-close {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-fast);
}

.presentation-close:hover {
    background-color: var(--bg-tertiary);
}

/* ==========================================================================
   Loading States
   ========================================================================== */

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-8);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--brand-color);
    border-radius: var(--radius-full);
    animation: spin 1s linear infinite;
}

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

/* ==========================================================================
   Tooltips
   ========================================================================== */

[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: var(--space-2) var(--space-3);
    background-color: var(--text-primary);
    color: var(--bg-secondary);
    font-size: var(--text-xs);
    white-space: nowrap;
    border-radius: var(--radius-sm);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    pointer-events: none;
    z-index: var(--z-tooltip);
}

[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
}

/* ==========================================================================
   Book/Chapter Dropdown
   ========================================================================== */

.dropdown-back {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background-color: var(--bg-tertiary);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.dropdown-back .material-symbols-outlined {
    font-size: 18px;
}

.book-chapters-badge {
    font-size: var(--text-xs);
    color: var(--text-muted);
    background-color: var(--bg-primary);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
}

.chapter-grid-dropdown {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-1);
    padding: var(--space-2);
    max-height: 300px;
    overflow-y: auto;
}

.chapter-btn-dropdown {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    transition: all var(--transition-fast);
}

.chapter-btn-dropdown:hover {
    background-color: var(--brand-light);
    border-color: var(--brand-color);
    color: var(--brand-color);
}

.dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
}


