/* ========================================
   MODAL COMPONENTS
   Modal Overlays, Cards, Forms, Fields
   ======================================== */


/* ========================================
   MODAL OVERLAY (Full-Screen Backdrop)
   ======================================== */

.modal-overlay {
    /* Positioning */
    position: fixed;
    inset: 0;   /* Shorthand for top:0, right:0, bottom:0, left:0 */
    z-index: var(--z-modal-backdrop);

    /* Layout */
    display: flex;
    align-items: center;
    justify-content: center;

    /* Styling */
    background: var(--color-overlay);
    backdrop-filter: blur(1px);

    /* Hidden by default */
    opacity: 0;
    pointer-events: none;

    /* Animation */
    transition: opacity 0.25s ease;
}

/* Show modal (JavaScript adds .show class) */
.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

/* ========================================
   MODAL CARD (Content Container)
   ======================================== */

.modal-card {
    /* Sizing */
    width: 520px;
    max-width: 92vw;    /* Don't overflow on mobile */

    /* Styling */
    background: var(--color-bg-sidebar);
    border-radius: 14px;
    border: 1px solid var(--color-bg-input);
    padding: var(--space-3xl) var(--space-3xl) 14px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.85);

    /* Initial state (before animation */
    transform: translateY(10px);
    opacity: 0;

    /* Animation */
    transition: all 0.25s ease;
}

/* Animate in when modal shown */
.modal-overlay.show .modal-card {
    transform: translateY(0);
    opacity: 1;
}

/* Wide modal variant (for more complex forms) */
.modal-card.wide {
    width: 640px;
    max-width: 96vw;
}

/* ========================================
   MODAL HEADER
   ======================================== */

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--gap-md);
}

.modal-header h2 {
    font-family: var(--font-heading);
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-semibold);
}

/* Close Button (x) */
.modal-close {
    /* Reset button styles */
    background: none;
    border: none;
    padding: 0;

    /* Styling */
    color: var(--color-text-muted);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;

    /* Animation */
    transition: color var(--transition-base);
}

.modal-close:hover {
    color: var(--color-primary);
}

/* ========================================
   MODAL BODY
   ======================================== */

.modal-body {
    margin-top: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--gap-md);
}

/* Modal Grid (Two-Column Form Layout) */
.modal-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-md);
}

/* Modal Hint Text */
.modal-hint {
    font-size: 0.7rem;
    color: var(--color-text-dim);
    font-style: italic;
    padding: var(--space-sm) 0;
}

/* Modal error/success messages */
.modal-error, 
.modal-success {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}

.modal-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.modal-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #10b981;
}

/* ========================================
   FORM FIELDS
   ======================================== */

.field {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    font-size: 0.78rem;
}

/* Field Label */
.field label {
    color: var(--color-text-lighter);
    font-size: 0.72rem;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    font-weight: var(--font-weight-medium);
}

/* Input, Select, Textarea Base Styles */
.field input, 
.field select, 
.field textarea {
    /* Sizing */
    padding: 7px 9px;

    /* Styling */
    background: var(--color-dark);
    border-radius: var(--radius-md);
    border: 1px solid #2a2a2a;
    color: var(--color-text-secondary);
    font-size: 0.78rem;

    /* Remove default outline */
    outline: none;

    /* Animation */
    transition: all 0.25s ease;
}

/* Focus State (When user clicks/tabs into field) */
.field input:focus, 
.field select:focus, 
.field textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 8px rgba(var(--color-primary-rgb), 0.5);
}

/* Hover State */
.field input:hover, 
.field select:hover, 
.field textarea:hover {
    border-color: rgba(var(--color-primary-rgb), 0.6);
}

/* Textarea Specific */
.field textarea {
    resize: vertical;   /* Allow vertical resizing only */
    min-height: 60px;
    font-family: inherit;   /* Uses same font as rest of app */
}

/* ========================================
   SELECT DROPDOWNS (Custom Styling)
   ======================================== */

.field select {
    /* Remove default arrows */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;

    /* Custom arrow using inline SVG */
     background: var(--color-dark) 
                url('data:image/svg+xml;utf8,<svg fill="%23aaa" height="12" width="12" xmlns="http://www.w3.org/2000/svg"><path d="M2 4l4 4 4-4z"/></svg>') 
                no-repeat right 10px center;
     background-size: 12px;

     /* Padding (extra space on right for arrow) */
     padding: 8px 30px 8px 9px;

     /* Styling */
     cursor: pointer;
}

/* ========================================
   MODAL FOOTER (Action Buttons)
   ======================================== */

.modal-footer {
    margin-top: var(--gap-md);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-md);
}

/* ========================================
   FORM VALIDATION STATES
   ======================================== */

/* Error State */
.field.error input, 
.field.error select, 
.field.error textarea {
    border-color: #ff4444;
}

.field .error-message {
    color: #ff4444;
    font-size: 0.7rem;
    margin-top: 2px;
}

/* Success State */
.field.success input, 
.field.success select, 
.field.success textarea {
    border-color: var(--color-success);
}

/* ========================================
   CHECKBOX & RADIO STYLES
   ======================================== */

.field input[type="checkbox"], 
.field input[type="radio"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--color-primary);
}

/* Checkbox/Radio Label (Next to box) */
.field.inline {
    flex-direction: row;
    align-items: center;
    gap: var(--space-md);
}

.field.inline label {
    text-transform: none;
    font-size: 0.85rem;
    cursor: pointer;
}

/* ========================================
   RESPONSIVE (Mobile)
   ======================================== */

@media (max-width: 640px) {
    /* Single column forms on mobile */
    .modal-grid {
        grid-template-columns: 1fr;
    }

    /* Smaller padding */
    .modal-card {
        padding: var(--space-2xl)
    }

    /* Stack buttons vertically */
    .modal-footer {
        flex-direction: column-reverse;
        gap: var(--space-md);
    }

    .modal-footer .btn {
        width: 100%;
    }
}

/* ========================================
   ACCESSIBILITY HELPERS
   ======================================== */

/* Focus-visible for keyboard navigation */
.modal-card:focus-visible, 
.field input:focus-visible, 
.field select:focus-visible, 
.field textarea:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* ========================================
   CHECK-IN SEARCH AUTOCOMPLETE
   Universal dropdown for check-in modal member search
   ======================================== */

.search-results-dropdown {
    /* Positioning */
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;

    /* Sizing */
    margin-top: 4px;
    max-height: 300px;

    /* Layout */
    overflow-y: auto;
    display: none;  /* Hidden by default, shown via JavaScript */

    /* Styling */
    background-color: var(--color-bg-sidebar);
    border: 1px solid var(--color-bg-input);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.search-result-item {
    /* Sizing */
    padding: 12px 16px;

    /* Styling */
    border-bottom: 1px solid var(--color-bg-input);
    cursor: pointer;

    /* Animation */
    transition: background 0.2s ease;
}

.search-result-item:hover {
    /* Styling */
    background: rgba(var(--color-primary-rgb), 0.1);
}

.search-result-item:last-child {
    /* Styling */
    border-bottom: none;
}

.search-result-name {
    /* Sizing */
    font-size: 0.9rem;

    /* Styling */
    font-weight: 600;
    color: var(--color-text-primary);
}

.search-result-details {
    /* Sizing */
    font-size: 0.75rem;
    margin-top: 4px;

    /* Styling */
    color: var(--color-text-muted);
}

.search-no-results {
    /* Sizing */
    padding: 16px;
    font-size: 0.85rem;

    /* Layout */
    text-align: center;

    /* Styling */
    color: var(--color-text-muted);
}

/* ========================================
   CHECK-IN NOTIFICATION CARDS
   Universal notifications for member check-ins (all pages)
   ======================================== */

.check-in-notifications {
    /* Positioning */
    position: fixed;
    bottom: 20px;  /* Below header */
    right: 20px;
    z-index: 10000; /* Above everything */

    /* Layout */
    display: flex;
    flex-direction: column;
    gap: 10px;

    /* Styling */
    pointer-events: none;   /* Don't block clicks on page */
}

.check-in-notification {
    /* Sizing */
    min-width: 300px;
    max-width: 350px;
    padding: 16px 20px;

    /* Styling */
    background: var(--color-bg-card);
    border-radius: 12px;
    border-left: 4px solid var(--color-primary);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    pointer-events: auto;   /* Re-enable for this element */

    /* Animation */
    animation: slideInRight 0.3s ease-out;
}

/* Success variant (green border) */
.check-in-notification.success {
    /* Styling */
    border-left-color: var(--color-success);
}

/* Notification Header */
.notification-header {
    /* Sizing */
    margin-bottom: 12px;
    
    /* Layout */
    display: flex;
    align-items: center;
    gap: 10px;
}

.notification-icon {
    /* Sizing */
    width: 36px;
    height: 36px;
    font-size: 18px;
    
    /* Layout */
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    
    /* Styling */
    border-radius: 50%;
    background: var(--color-success);
    color: white;
}

.notification-title {
    /* Sizing */
    font-size: 14px;
    
    /* Styling */
    font-weight: 600;
    color: var(--color-text-primary);
}

/* Notification Body */
.notification-body {
    /* Layout */
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.notification-member {
    /* Sizing */
    font-size: 16px;
    
    /* Styling */
    font-weight: 600;
    color: var(--color-text-primary);
}

.notification-details {
    /* Sizing */
    font-size: 13px;
    
    /* Layout */
    display: flex;
    gap: 16px;
    
    /* Styling */
    color: var(--color-text-muted);
}

.notification-time,
.notification-location {
    /* Layout */
    display: flex;
    align-items: center;
    gap: 6px;
}

.notification-time i,
.notification-location i {
    /* Sizing */
    font-size: 12px;
    
    /* Styling */
    color: var(--color-success);
}

/* Fade out state (triggered by JavaScript) */
.check-in-notification.fade-out {
    /* Animation */
    animation: fadeOut 0.5s ease-out forwards;
}

/* ========================================
   NOTIFICATION ANIMATIONS
   ======================================== */

@keyframes slideInRight {
    from {
        /* Positioning */
        transform: translateX(400px);
        
        /* Styling */
        opacity: 0;
    }
    to {
        /* Positioning */
        transform: translateX(0);
        
        /* Styling */
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        /* Positioning */
        transform: translateX(0);
        
        /* Styling */
        opacity: 1;
    }
    to {
        /* Positioning */
        transform: translateX(100px);
        
        /* Styling */
        opacity: 0;
    }
}

/* ========================================
   RESPONSIVE (Mobile)
   ======================================== */

@media (max-width: 768px) {
    .check-in-notifications {
        /* Positioning */
        right: 10px;
        left: 10px;
        top: 70px;
    }
    
    .check-in-notification {
        /* Sizing */
        min-width: auto;
        max-width: none;
    }
}

/* ========================================
   TOAST NOTIFICATIONS (Errors, Warnings)
   ======================================== */

.toast-notification {
    /* Positioning */
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    z-index: 10001;

    /* Sizing */
    min-width: 300px;
    max-width: 500px;
    padding: 14px 18px;

    /* Layout */
    display: flex;
    align-items: center;
    gap: 12px;

    /* Styling */
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    border-left: 4px solid var(--color-primary);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);

    /* Animation */
    opacity: 0;
    transition: all 0.3s ease;
}

.toast-notification.show {
    /* Positioning */
    transform: translateX(-50%) translateY(0);

    /* Styling */
    opacity: 1;
}

.toast-notification.success {
    /* Styling */
    border-left: 4px solid var(--color-success, #10b981);
}

.toast-notification.sucess i {
    /* Styling */
    color: var(--color-success, #10b981);

    /* Sizing */
    font-size: 1.2rem;
}

.toast-notification.error {
    /* Styling */
    border-left: 4px solid var(--color-danger, #ef4444);
}

.toast-notification.error i {
    /* Styling */
    color: var(--color-danger, #ef4444);

    /* Sizing */
    font-size: 1.2rem;
}

.toast-notification-info {
    /* Styling */
    border-left-color: var(--color-primary);
}

.toast-icon {
    /* Sizing */
    font-size: 20px;

    /* Styling */
    color: var(--color-primary);
    flex-shrink: 0;
}

.toast-notification.error .toast-icon {
    /* Styling */
    color: #ff4444;
}

.toast-message {
    /* Sizing */
    font-size: 0.9rem;

    /* Styling */
    color: var(--color-text-primary);
    flex: 1;
}

/* ========================================
   FIELD WARNING (Location Mismatch Alert)
   ======================================== */

.field-warning {
    /* Sizing */
    font-size: 0.75rem;
    margin-top: 6px;
    padding: 8px 10px;
    
    /* Layout */
    display: flex;
    align-items: center;
    gap: 8px;
    
    /* Styling */
    color: #f39c12;
    background: rgba(243, 156, 18, 0.1);
    border-left: 3px solid #f39c12;
    border-radius: var(--radius-sm);
}

.field-warning i {
    /* Sizing */
    font-size: 0.85rem;
    
    /* Styling */
    flex-shrink: 0;
}

.field-warning span {
    /* Styling */
    flex: 1;
}