/* Reset and base styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --color-primary: #1a56db;
    --color-primary-hover: #1e40af;
    --color-success: #059669;
    --color-warning: #d97706;
    --color-danger: #dc2626;
    --color-text: #1f2937;
    --color-text-muted: #6b7280;
    --color-bg: #f9fafb;
    --color-card: #ffffff;
    --color-border: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 8px;
    --radius-lg: 12px;
}

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

/* Layout */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

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

.header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.tagline {
    color: var(--color-text-muted);
    font-size: 1.125rem;
}

/* Search Section */
.search-section {
    margin-bottom: 2rem;
}

.search-form {
    margin-bottom: 0.75rem;
}

.input-wrapper {
    display: flex;
    gap: 0.5rem;
    background: var(--color-card);
    padding: 0.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
}

#search-input {
    flex: 1;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: none;
    background: transparent;
    outline: none;
    color: var(--color-text);
}

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

#search-btn {
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background-color: var(--color-primary);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

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

#search-btn:active:not(:disabled) {
    transform: scale(0.98);
}

#search-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

#search-btn.loading {
    position: relative;
}

.input-hint {
    font-size: 0.875rem;
    color: var(--color-primary);
    margin-top: 0.5rem;
    padding-left: 0.5rem;
}

.examples {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    text-align: center;
}

.example {
    display: inline-block;
    background: var(--color-card);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9rem;
    margin: 0 0.125rem;
    cursor: pointer;
    transition: opacity 0.3s ease, background-color 0.2s;
    border: 1px solid var(--color-border);
}

.example:hover {
    background: #e5e7eb;
}

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

/* ===========================================
   LOADING OVERLAY - Engaging waiting UX
   =========================================== */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s ease;
}

#loading-overlay.visible {
    opacity: 1;
}

.loading-content {
    text-align: center;
    padding: 2rem;
    max-width: 400px;
}

/* Triple ring spinner */
.loading-spinner {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
}

.spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid transparent;
}

.spinner-ring:nth-child(1) {
    border-top-color: var(--color-primary);
    animation: spin 1.2s linear infinite;
}

.spinner-ring:nth-child(2) {
    width: 70%;
    height: 70%;
    top: 15%;
    left: 15%;
    border-right-color: #60a5fa;
    animation: spin 1.5s linear infinite reverse;
}

.spinner-ring:nth-child(3) {
    width: 40%;
    height: 40%;
    top: 30%;
    left: 30%;
    border-bottom-color: #93c5fd;
    animation: spin 1s linear infinite;
}

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

.loading-message {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 0.5rem;
    min-height: 1.5em;
    transition: opacity 0.3s ease;
}

.loading-subtext {
    font-size: 0.9375rem;
    color: var(--color-text-muted);
    margin: 0;
    min-height: 1.25em;
}

.loading-escape {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
    animation: fadeIn 0.5s ease;
}

.loading-escape p {
    font-size: 0.9375rem;
    color: var(--color-text-muted);
    margin: 0 0 0.75rem;
}

.escape-link {
    display: inline-block;
    padding: 0.75rem 1.25rem;
    background: var(--color-bg);
    border: 2px solid var(--color-primary);
    color: var(--color-primary);
    font-weight: 600;
    font-size: 0.9375rem;
    border-radius: var(--radius);
    text-decoration: none;
    transition: all 0.2s ease;
}

.escape-link:hover {
    background: var(--color-primary);
    color: white;
}

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

/* Mobile adjustments for loading */
@media (max-width: 640px) {
    .loading-spinner {
        width: 60px;
        height: 60px;
    }

    .loading-message {
        font-size: 1.0625rem;
    }

    .escape-link {
        padding: 1rem 1.5rem;
        font-size: 1rem;
        min-height: 48px;
    }
}

/* Error Section */
.error-section {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--color-danger);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

/* Results Section */
.results-section {
    margin-bottom: 2rem;
}

.results-count {
    color: var(--color-text-muted);
    margin-bottom: 1rem;
    font-size: 0.9375rem;
}

.results-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.result-card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}

.result-card:hover {
    box-shadow: var(--shadow-md);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

.result-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.license-number {
    font-family: monospace;
    font-size: 0.9375rem;
    background: #f3f4f6;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    color: var(--color-text);
    white-space: nowrap;
}

.result-details {
    display: grid;
    gap: 0.5rem;
}

.detail-row {
    display: flex;
    gap: 0.5rem;
    font-size: 0.9375rem;
}

.detail-row .label {
    color: var(--color-text-muted);
    min-width: 70px;
}

.detail-row .value {
    color: var(--color-text);
    font-weight: 500;
}

.status-ok {
    color: var(--color-success);
}

.status-warn {
    color: var(--color-warning);
}

/* No Results Section */
.no-results-section {
    margin-bottom: 2rem;
}

.no-results-content {
    text-align: center;
    padding: 3rem 1.5rem;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

.no-results-icon {
    width: 48px;
    height: 48px;
    color: var(--color-text-muted);
    margin-bottom: 1rem;
}

.no-results-content h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.no-results-content p {
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
}

.no-results-content a {
    color: var(--color-primary);
    text-decoration: none;
}

.no-results-content a:hover {
    text-decoration: underline;
}

/* Suggestions Section */
.suggestions-section {
    background: #fffbeb;
    border: 1px solid #fef3c7;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 2rem;
}

.suggestions-section h4 {
    font-size: 0.9375rem;
    margin-bottom: 0.5rem;
    color: #92400e;
}

.suggestions-section ul {
    list-style: none;
    color: #92400e;
    font-size: 0.9375rem;
}

.suggestions-section li {
    padding: 0.25rem 0;
}

.suggestions-section li::before {
    content: "• ";
    color: #d97706;
}

/* Recommendation */
.recommendation {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 2rem;
}

.recommendation p {
    font-size: 0.9375rem;
    color: #0369a1;
    line-height: 1.7;
    margin: 0;
}

.recommendation a {
    color: #0284c7;
    font-weight: 600;
    text-decoration: none;
}

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

/* Fraud Stats - Clickable rotating banner */
.fraud-stats {
    text-align: center;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    border-radius: var(--radius);
    background: #fafafa;
    border: 1px solid #e5e7eb;
}

.stat-link {
    display: inline-block;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.stat-text {
    font-size: 0.875rem;
    color: #6b7280;
    font-style: italic;
    transition: opacity 0.4s ease, color 0.2s ease;
    display: inline;
    border-bottom: 2px solid transparent;
}

/* Hover: show underline and change color */
.stat-link:hover .stat-text {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

/* Focus state for accessibility */
.stat-link:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 4px;
    border-radius: 2px;
}

.stat-link:focus .stat-text {
    color: var(--color-primary);
}

/* Footer */
.footer {
    text-align: center;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.footer p {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
}

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

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

.disclaimer {
    font-size: 0.8125rem !important;
    font-style: italic;
}

.attribution {
    margin-top: 1rem;
    font-size: 0.8125rem;
}

/* Hover-only underline for footer attribution links */
.hover-underline {
    text-decoration: none;
    color: var(--color-primary);
    transition: text-decoration 0.2s ease;
}

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

.hover-underline:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ===========================================
   MOBILE & SENIOR-FRIENDLY RESPONSIVE STYLES
   Touch targets: minimum 48px (WCAG AAA)
   Font sizes: larger for readability
   =========================================== */

@media (max-width: 640px) {
    /* Larger base font for seniors */
    body {
        font-size: 18px;
        line-height: 1.7;
    }

    .container {
        padding: 1.5rem 1rem;
    }

    /* Larger, clearer header */
    .header h1 {
        font-size: 1.625rem;
        line-height: 1.3;
    }

    .tagline {
        font-size: 1.125rem;
        margin-top: 0.5rem;
    }

    /* Stack search input and button vertically */
    .input-wrapper {
        flex-direction: column;
        padding: 0.75rem;
        gap: 0.75rem;
    }

    /* Larger input field - minimum 48px touch target */
    #search-input {
        padding: 1rem 1.25rem;
        font-size: 1.125rem;
        min-height: 52px;
        border: 2px solid var(--color-border);
        border-radius: var(--radius);
    }

    #search-input:focus {
        border-color: var(--color-primary);
        outline: 3px solid rgba(26, 86, 219, 0.2);
    }

    /* Large, easy-to-tap search button */
    #search-btn {
        width: 100%;
        padding: 1rem 1.5rem;
        font-size: 1.125rem;
        min-height: 52px;
        border-radius: var(--radius);
    }

    /* Larger example pill - easy to tap */
    .examples {
        font-size: 1rem;
        margin-top: 1rem;
    }

    .example {
        padding: 0.625rem 1rem;
        font-size: 1rem;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        margin: 0.25rem;
    }

    /* Input hint - larger text */
    .input-hint {
        font-size: 1rem;
        padding: 0.5rem;
    }

    /* Results - larger text and spacing */
    .results-count {
        font-size: 1.0625rem;
    }

    .result-card {
        padding: 1.5rem;
    }

    .result-header {
        flex-direction: column;
        gap: 0.75rem;
    }

    .result-header h3 {
        font-size: 1.25rem;
    }

    .license-number {
        font-size: 1.0625rem;
        padding: 0.375rem 0.75rem;
        align-self: flex-start;
    }

    .detail-row {
        font-size: 1.0625rem;
        padding: 0.25rem 0;
    }

    .detail-row .label {
        min-width: 80px;
    }

    /* Fraud stats - larger text */
    .fraud-stats {
        padding: 1.25rem;
    }

    .stat-text {
        font-size: 1rem;
        line-height: 1.5;
    }

    /* Error section - larger */
    .error-section {
        padding: 1.25rem;
        font-size: 1.0625rem;
    }

    /* No results - larger */
    .no-results-content {
        padding: 2.5rem 1.5rem;
    }

    .no-results-content h3 {
        font-size: 1.375rem;
    }

    .no-results-content p {
        font-size: 1.0625rem;
    }

    /* Links - larger tap targets */
    .no-results-content a,
    .footer a {
        display: inline-block;
        padding: 0.5rem 0;
        min-height: 44px;
    }

    /* Footer - larger text */
    .footer p {
        font-size: 1rem;
    }

    .disclaimer {
        font-size: 0.9375rem !important;
    }

    /* Attribution links - easy to tap for seniors */
    .attribution {
        font-size: 0.9375rem;
        margin-top: 1.25rem;
    }

    .hover-underline {
        display: inline-block;
        padding: 0.5rem 0.25rem;
        min-height: 44px;
        line-height: 1.5;
    }
}

/* Extra large screens / desktop - slightly larger for seniors */
@media (min-width: 1024px) {
    body {
        font-size: 17px;
    }

    .header h1 {
        font-size: 2.25rem;
    }

    .tagline {
        font-size: 1.25rem;
    }

    #search-input {
        font-size: 1.125rem;
        padding: 1rem 1.25rem;
    }

    #search-btn {
        padding: 1rem 2rem;
        font-size: 1.0625rem;
    }
}
