/**
 * Finnish Bible Search - Styles
 * ==============================
 * 
 * Purpose:
 *     Professional, eye-pleasing design with vintage Bible background
 * 
 * Features:
 *     - Vintage Bible background (opacity 0.2)
 *     - Responsive design (mobile, tablet, desktop)
 *     - Accessible color contrast
 *     - Modern UI with classic typography
 *     - Print-friendly styles
 * 
 * Structure:
 *     1. CSS Variables (colors, fonts, spacing)
 *     2. Reset & Base Styles
 *     3. Layout & Container
 *     4. Typography
 *     5. Components (forms, buttons, tables)
 *     6. Responsive Design
 *     7. Print Styles
 * 
 * Author: Created for Dale Herva
 * Date: March 17, 2026
 */

/* ========================================================================
   1. CSS VARIABLES
   ======================================================================== */

:root {
    /* Colors - Professional palette with good contrast */
    --primary-color: #2c5aa0;        /* Deep blue for primary actions */
    --primary-hover: #234785;        /* Darker blue for hover states */
    --secondary-color: #6c757d;      /* Gray for secondary actions */
    --secondary-hover: #5a6268;      /* Darker gray for hover */
    --success-color: #28a745;        /* Green for success messages */
    --danger-color: #dc3545;         /* Red for errors */
    --warning-color: #ffc107;        /* Yellow for warnings */
    
    /* Backgrounds */
    --background: #f5f7fa;           /* Light gray page background */
    --surface: #ffffff;              /* White card surface */
    --surface-hover: #f8f9fa;        /* Light hover state */
    
    /* Text colors */
    --text-primary: #212529;         /* Dark gray for body text */
    --text-secondary: #6c757d;       /* Medium gray for hints */
    --text-muted: #adb5bd;           /* Light gray for disabled */
    
    /* Borders & Shadows */
    --border-color: #dee2e6;         /* Light border */
    --border-radius: 8px;            /* Rounded corners */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
    
    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 
                   'Helvetica Neue', Arial, sans-serif;
    --font-family-serif: Georgia, 'Times New Roman', serif;
    --font-size-base: 16px;
    --font-size-sm: 0.875rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.5rem;
    --font-size-2xl: 2rem;
    --line-height-base: 1.6;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* Transitions */
    --transition-fast: 150ms ease-in-out;
    --transition-base: 250ms ease-in-out;
    --transition-slow: 350ms ease-in-out;
}

/* ========================================================================
   2. RESET & BASE STYLES
   ======================================================================== */

/**
 * Box sizing reset
 * Ensures padding and border are included in element width/height
 */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/**
 * Body base styles
 * Sets up the vintage Bible background
 */
body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: var(--line-height-base);
    color: var(--text-primary);
    background-color: var(--background);
    
    /* Vintage Bible background image */
    background-image: url('../images/bible-bg.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    
    /* Low opacity overlay for readability */
    position: relative;
    min-height: 100vh;
    padding: var(--spacing-lg);
}

/**
 * Background overlay
 * Creates semi-transparent white layer over Bible image
 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.88);
    z-index: -1;
    pointer-events: none;
}

/* ========================================================================
   3. LAYOUT & CONTAINER
   ======================================================================== */

/**
 * Main container
 * Centers content with max-width for readability
 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* ========================================================================
   4. TYPOGRAPHY
   ======================================================================== */

/**
 * Header title styling
 */
.header {
    text-align: center;
    margin-bottom: var(--spacing-2xl);
    padding: var(--spacing-xl);
    background: var(--surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
}

.header-title {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: var(--spacing-sm);
    font-family: var(--font-family-serif);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
}

.header-icon {
    font-size: 2.5rem;
}

.header-subtitle {
    font-size: var(--font-size-lg);
    color: var(--text-secondary);
    font-style: italic;
}

/**
 * Section titles
 */
.section-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-sm);
    border-bottom: 2px solid var(--border-color);
}

/* ========================================================================
   5. COMPONENTS
   ======================================================================== */

/* --- Search Groups --- */

/**
 * Search group container
 * White card with shadow for each search method
 */
.search-group {
    background: var(--surface);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    transition: box-shadow var(--transition-base);
}

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

.search-controls {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.control-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-lg);
    align-items: flex-end;
}

/* --- Form Groups --- */

/**
 * Form group - wrapper for label + input
 */
.form-group {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.form-group-wide {
    flex: 2;
    min-width: 300px;
}

.form-group-small {
    flex: 0 1 150px;
    min-width: 120px;
}

/**
 * Form labels
 */
.form-label {
    font-weight: 600;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    display: block;
}

.required {
    color: var(--danger-color);
}

/**
 * Form hints (small text under inputs)
 */
.form-hint {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    font-style: italic;
}

/* --- Form Inputs --- */

/**
 * Select dropdowns
 */
.form-select {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: var(--font-size-base);
    font-family: var(--font-family);
    color: var(--text-primary);
    background-color: var(--surface);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.form-select:hover:not(:disabled) {
    border-color: var(--primary-color);
}

.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(44, 90, 160, 0.1);
}

.form-select:disabled {
    background-color: var(--surface-hover);
    cursor: not-allowed;
    opacity: 0.6;
}

/**
 * Text and number inputs
 */
.form-input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: var(--font-size-base);
    font-family: var(--font-family);
    color: var(--text-primary);
    background-color: var(--surface);
    transition: all var(--transition-fast);
}

.form-input:hover {
    border-color: var(--primary-color);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(44, 90, 160, 0.1);
}

.form-input::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

/* --- Buttons --- */

/**
 * Button row container
 */
.button-row {
    display: flex;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

/**
 * Base button styles
 */
.btn {
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none;
    border-radius: var(--border-radius);
    font-size: var(--font-size-base);
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/**
 * Primary button (main actions)
 */
.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

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

/**
 * Secondary button (reset, cancel)
 */
.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

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

/* --- Results Section --- */

/**
 * Results container
 */
.results-section {
    background: var(--surface);
    padding: var(--spacing-xl);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
}

/**
 * Results info text
 */
.results-info {
    padding: var(--spacing-md) 0;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 600;
}

/* --- Loading Indicator --- */

/**
 * Loading spinner container
 */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-2xl);
    gap: var(--spacing-lg);
}

/**
 * Animated spinner
 */
.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* --- Results Table --- */

/**
 * Table container with horizontal scroll
 */
.table-container {
    overflow-x: auto;
    margin-top: var(--spacing-lg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

/**
 * Results table
 */
.results-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    font-size: var(--font-size-base);
}

/**
 * Table header
 */
.results-table thead {
    background-color: var(--primary-color);
    color: white;
}

.results-table th {
    padding: var(--spacing-md);
    text-align: left;
    font-weight: 600;
    font-size: var(--font-size-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

/**
 * Table body rows
 */
.results-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color var(--transition-fast);
}

.results-table tbody tr:hover {
    background-color: var(--surface-hover);
}

.results-table tbody tr:last-child {
    border-bottom: none;
}

/**
 * Table cells
 */
.results-table td {
    padding: var(--spacing-md);
    vertical-align: top;
}

/* Book, Chapter, Verse columns - compact */
.results-table td:nth-child(1),
.results-table td:nth-child(2),
.results-table td:nth-child(3) {
    white-space: nowrap;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

/* Text column - readable */
.results-table td:nth-child(4) {
    line-height: 1.7;
    font-family: var(--font-family-serif);
}

/**
 * No results message
 */
.no-results {
    text-align: center;
    padding: var(--spacing-2xl) var(--spacing-lg) !important;
    color: var(--text-secondary);
    font-style: italic;
}

/**
 * Error message
 */
.error-message {
    background-color: #f8d7da;
    color: #721c24;
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--border-radius);
    border: 1px solid #f5c6cb;
    margin-top: var(--spacing-lg);
}

/* --- Footer --- */

/**
 * Footer section
 */
.footer {
    text-align: center;
    padding: var(--spacing-xl) var(--spacing-lg);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

.separator {
    margin: 0 var(--spacing-sm);
}

/* ========================================================================
   6. RESPONSIVE DESIGN
   ======================================================================== */

/**
 * Tablet and below (768px)
 */
@media (max-width: 768px) {
    body {
        padding: var(--spacing-md);
    }
    
    .header {
        padding: var(--spacing-lg);
    }
    
    .header-title {
        font-size: var(--font-size-xl);
    }
    
    .header-icon {
        font-size: 2rem;
    }
    
    .search-group {
        padding: var(--spacing-lg);
    }
    
    .control-row {
        flex-direction: column;
    }
    
    .form-group,
    .form-group-wide,
    .form-group-small {
        width: 100%;
        min-width: 100%;
    }
    
    .button-row {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .results-table {
        font-size: var(--font-size-sm);
    }
    
    .results-table th,
    .results-table td {
        padding: var(--spacing-sm);
    }
}

/**
 * Mobile (480px and below)
 */
@media (max-width: 480px) {
    .header-title {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    .section-title {
        font-size: var(--font-size-lg);
    }
    
    /* Stack table columns vertically on very small screens */
    .results-table,
    .results-table thead,
    .results-table tbody,
    .results-table tr,
    .results-table th,
    .results-table td {
        display: block;
    }
    
    .results-table thead {
        display: none;
    }
    
    .results-table tr {
        margin-bottom: var(--spacing-lg);
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius);
    }
    
    .results-table td {
        text-align: left;
        padding: var(--spacing-sm) var(--spacing-md);
        border-bottom: 1px solid var(--border-color);
    }
    
    .results-table td:last-child {
        border-bottom: none;
    }
    
    .results-table td::before {
        content: attr(data-label);
        font-weight: 600;
        display: block;
        margin-bottom: var(--spacing-xs);
        color: var(--primary-color);
    }
}

/* ========================================================================
   7. PRINT STYLES
   ======================================================================== */

/**
 * Print-friendly styles
 */
@media print {
    body {
        background: white;
        background-image: none;
        padding: 0;
    }
    
    body::before {
        display: none;
    }
    
    .search-group,
    .footer {
        display: none;
    }
    
    .results-section {
        box-shadow: none;
        padding: 0;
    }
    
    .results-table {
        box-shadow: none;
    }
    
    .results-table tbody tr:hover {
        background: transparent;
    }
    
    /* Ensure text is black for printing */
    .results-table td {
        color: black;
    }
}
