/* ========================================
   UX ENHANCEMENTS - Page-Specific Overrides
   ======================================== */

/* This file contains page-specific UX enhancements and overrides
   All base styles are defined in style.css */

/* ===== Visual Hierarchy Enhancements ===== */
h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: var(--space-md);
    color: var(--text-primary);
}

/* Lead text for important content */
.lead {
    font-size: 1.25rem;
    line-height: 1.6;
    color: var(--text-primary);
    margin-bottom: var(--space-xl);
}

/* ===== Hero Section Enhancements ===== */
.hero-section {
    padding: var(--space-3xl) 0;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--surface-primary) 100%);
    border-radius: var(--radius-xl);
    margin-bottom: var(--space-2xl);
}

/* Mobile hero optimizations */
@media (max-width: 768px) {
    .hero-section {
        padding: var(--space-lg) 0;
        margin-bottom: var(--space-lg);
        border-radius: var(--radius-md);
    }
}

@media (max-width: 480px) {
    .hero-section {
        padding: var(--space-md) 0;
        margin-bottom: var(--space-md);
        border-radius: var(--radius-sm);
    }
}

/* ===== Spacing Utilities ===== */
.section-spacing {
    margin-bottom: var(--space-2xl);
}

.content-spacing {
    margin-bottom: var(--space-xl);
}

/* ===== Loading Overlay for API Calls ===== */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: var(--radius-lg, 0.5rem);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loading-overlay .spinner-content {
    text-align: center;
    padding: var(--space-lg, 1.5rem);
}

.loading-overlay .spinner-icon {
    font-size: 2.5rem;
    color: var(--color-primary, #007bff);
    animation: spin 1s linear infinite;
}

.loading-overlay .spinner-text {
    margin-top: var(--space-md, 1rem);
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary, #6c757d);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Dark mode loading overlay */
[data-theme="dark"] .loading-overlay {
    background: rgba(30, 30, 30, 0.85);
}

[data-theme="dark"] .loading-overlay .spinner-text {
    color: rgba(255, 255, 255, 0.8);
}

/* Loading button state enhancement */
button.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

button.loading:disabled {
    cursor: not-allowed;
}

/* ===== Toast Notifications (Standardized Success/Error Messages) ===== */
/* Note: Add role="region" aria-live="polite" aria-atomic="true" to toast container in HTML */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-md, 1rem);
    max-width: 400px;
}

.toast {
    background: white;
    border-radius: var(--radius-lg, 0.5rem);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: var(--space-md, 1rem) var(--space-lg, 1.5rem);
    display: flex;
    align-items: flex-start;
    gap: var(--space-md, 1rem);
    border-left: 4px solid;
    animation: slideInRight 0.3s ease-out;
    min-width: 300px;
    position: relative;
}

.toast.hiding {
    animation: slideOutRight 0.3s ease-out forwards;
}

.toast-success {
    border-left-color: #28a745;
    background: linear-gradient(to right, rgba(40, 167, 69, 0.1), white);
}

.toast-error {
    border-left-color: #dc3545;
    background: linear-gradient(to right, rgba(220, 53, 69, 0.1), white);
}

.toast-warning {
    border-left-color: #ffc107;
    background: linear-gradient(to right, rgba(255, 193, 7, 0.1), white);
}

.toast-info {
    border-left-color: #17a2b8;
    background: linear-gradient(to right, rgba(23, 162, 184, 0.1), white);
}

.toast-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.toast-success .toast-icon { color: #28a745; }
.toast-error .toast-icon { color: #dc3545; }
.toast-warning .toast-icon { color: #ffc107; }
.toast-info .toast-icon { color: #17a2b8; }

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.25rem;
    color: var(--text-primary, #212529);
}

.toast-message {
    font-size: 0.875rem;
    color: var(--text-secondary, #6c757d);
    margin: 0;
}

.toast-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-secondary, #6c757d);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.toast-close:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* Dark mode toast adjustments */
[data-theme="dark"] .toast {
    background: var(--surface-secondary, #2d3748);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .toast-success {
    background: linear-gradient(to right, rgba(40, 167, 69, 0.2), var(--surface-secondary, #2d3748));
}

[data-theme="dark"] .toast-error {
    background: linear-gradient(to right, rgba(220, 53, 69, 0.2), var(--surface-secondary, #2d3748));
}

[data-theme="dark"] .toast-warning {
    background: linear-gradient(to right, rgba(255, 193, 7, 0.2), var(--surface-secondary, #2d3748));
}

[data-theme="dark"] .toast-info {
    background: linear-gradient(to right, rgba(23, 162, 184, 0.2), var(--surface-secondary, #2d3748));
}

[data-theme="dark"] .toast-title {
    color: rgba(255, 255, 255, 0.95);
}

[data-theme="dark"] .toast-message {
    color: rgba(255, 255, 255, 0.7);
}

[data-theme="dark"] .toast-close {
    color: rgba(255, 255, 255, 0.7);
}

[data-theme="dark"] .toast-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .toast-container {
        top: 10px; /* Reduced since header is no longer sticky on mobile */
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .toast {
        min-width: auto;
        padding: var(--space-sm, 0.75rem) var(--space-md, 1rem);
    }

    .toast-icon {
        font-size: 1.25rem;
    }

    .toast-title {
        font-size: 0.9rem;
    }

    .toast-message {
        font-size: 0.8rem;
    }
}

/* ===== Mobile Form Optimizations ===== */
@media (max-width: 768px) {
    /* Increase touch target sizes for mobile */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px; /* Prevents iOS zoom on focus */
        min-height: 44px; /* Apple's recommended touch target */
        padding: 12px 16px;
    }

    /* Optimize button sizes for touch */
    .btn {
        min-height: 44px;
        padding: 12px 20px;
        font-size: 16px;
    }

    .btn-sm {
        min-height: 36px;
        padding: 8px 16px;
        font-size: 14px;
    }

    .btn-lg {
        min-height: 52px;
        padding: 14px 24px;
        font-size: 18px;
    }

    /* Improve form group spacing on mobile */
    .mb-3 {
        margin-bottom: 1.5rem !important;
    }

    /* Make labels more prominent on mobile */
    .form-label {
        font-size: 15px;
        font-weight: 600;
        margin-bottom: 8px;
        display: block;
    }

    /* Optimize checkbox and radio buttons */
    .form-check-input {
        width: 20px;
        height: 20px;
        margin-top: 2px;
    }

    .form-check-label {
        font-size: 15px;
        padding-left: 8px;
    }

    /* Better spacing for form validation feedback */
    .invalid-feedback,
    .valid-feedback {
        font-size: 14px;
        margin-top: 6px;
    }

    /* Optimize input groups for mobile */
    .input-group {
        flex-wrap: nowrap;
    }

    .input-group .btn {
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Card optimizations for mobile forms */
    .card {
        border-radius: var(--radius-md, 0.375rem);
    }

    .card-body {
        padding: 1.25rem;
    }

    /* Improve select dropdown appearance */
    select.form-control,
    select.form-select {
        background-size: 16px 16px;
        padding-right: 40px;
    }

    /* Optimize form text and help text */
    .form-text,
    small.form-text {
        font-size: 13px;
        line-height: 1.4;
        margin-top: 6px;
        display: block;
    }

    /* Stack form buttons vertically on mobile */
    .d-grid.gap-2.d-md-flex {
        flex-direction: column-reverse;
    }

    .d-grid.gap-2.d-md-flex > * {
        width: 100% !important;
    }

    /* Improve alert spacing on mobile */
    .alert {
        padding: 12px 16px;
        font-size: 14px;
        margin-bottom: 1rem;
    }

    /* Optimize form sections */
    .row {
        margin-left: 0;
        margin-right: 0;
    }

    .row > [class*="col-"] {
        padding-left: 0;
        padding-right: 0;
    }
}

/* Extra optimizations for very small screens */
@media (max-width: 576px) {
    /* Further increase touch targets on very small screens */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    input[type="date"],
    select,
    textarea {
        min-height: 48px;
        font-size: 16px;
    }

    .btn {
        min-height: 48px;
        font-size: 16px;
    }

    /* Reduce padding in cards on very small screens */
    .card-body {
        padding: 1rem;
    }

    /* Optimize modal dialogs */
    .modal-dialog {
        margin: 0.5rem;
    }

    /* Better form field focus states for mobile */
    input:focus,
    select:focus,
    textarea:focus {
        border-width: 2px;
        box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
    }
}

/* Landscape mode optimizations for mobile */
@media (max-width: 896px) and (orientation: landscape) {
    /* Reduce vertical spacing in landscape */
    .mb-3 {
        margin-bottom: 0.75rem !important;
    }

    .card-body {
        padding: 1rem;
    }

    /* Compact form layout in landscape */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    input[type="date"],
    select,
    textarea {
        min-height: 40px;
        padding: 10px 14px;
    }

    .btn {
        min-height: 40px;
        padding: 10px 18px;
    }
}
