/**
 * Public Styles - Guide Availability Calendar
 * Responsive + Light/Dark Mode Support
 */

/* ========================================
   CSS Variables - Light Mode (Default)
   ======================================== */
:root {
    --gac-primary-color: #3788d8;
    --gac-primary-hover: #2563eb;
    --gac-morning-color: #f59e0b;
    --gac-morning-bg: #fef3c7;
    --gac-morning-text: #92400e;
    --gac-afternoon-color: #10b981;
    --gac-afternoon-bg: #d1fae5;
    --gac-afternoon-text: #065f46;
    
    /* Light mode colors */
    --gac-bg-primary: #ffffff;
    --gac-bg-secondary: #f3f4f6;
    --gac-bg-tertiary: #e5e7eb;
    --gac-text-primary: #1f2937;
    --gac-text-secondary: #4b5563;
    --gac-text-muted: #9ca3af;
    --gac-border-color: #e5e7eb;
    --gac-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --gac-shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

/* ========================================
   Dark Mode - Auto Detection
   ======================================== */
@media (prefers-color-scheme: dark) {
    :root {
        --gac-bg-primary: #1f2937;
        --gac-bg-secondary: #111827;
        --gac-bg-tertiary: #374151;
        --gac-text-primary: #f9fafb;
        --gac-text-secondary: #e5e7eb;
        --gac-text-muted: #9ca3af;
        --gac-border-color: #374151;
        --gac-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
        --gac-shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
        
        /* Adjusted badge colors for dark mode */
        --gac-morning-bg: rgba(245, 158, 11, 0.25);
        --gac-morning-text: #fbbf24;
        --gac-afternoon-bg: rgba(16, 185, 129, 0.25);
        --gac-afternoon-text: #34d399;
    }
}

/* Dark mode class support (for themes that use .dark class) */
.dark .gac-public-calendar-wrapper,
[data-theme="dark"] .gac-public-calendar-wrapper,
body.flavor-flavor-flavor-flavor-flavor .gac-public-calendar-wrapper {
    --gac-bg-primary: #1f2937;
    --gac-bg-secondary: #111827;
    --gac-bg-tertiary: #374151;
    --gac-text-primary: #f9fafb;
    --gac-text-secondary: #e5e7eb;
    --gac-text-muted: #9ca3af;
    --gac-border-color: #374151;
    --gac-morning-bg: rgba(245, 158, 11, 0.25);
    --gac-morning-text: #fbbf24;
    --gac-afternoon-bg: rgba(16, 185, 129, 0.25);
    --gac-afternoon-text: #34d399;
}

/* ========================================
   Calendar Wrapper
   ======================================== */
.gac-public-calendar-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    max-width: 900px;
    margin: 0 auto;
    background: var(--gac-bg-primary);
    border-radius: 16px;
    box-shadow: var(--gac-shadow);
    overflow: hidden;
    position: relative;
    color: var(--gac-text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   Calendar Header
   ======================================== */
.gac-calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--gac-primary-color);
    color: #fff;
    gap: 10px;
}

.gac-month-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
    flex: 1;
    white-space: nowrap;
}

.gac-nav-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    color: #fff;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
    -webkit-tap-highlight-color: transparent;
}

.gac-nav-btn:hover,
.gac-nav-btn:active {
    background: rgba(255, 255, 255, 0.3);
}

.gac-nav-btn svg {
    display: block;
    width: 20px;
    height: 20px;
}

/* ========================================
   Legend
   ======================================== */
.gac-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 12px 16px;
    background: var(--gac-bg-secondary);
    border-bottom: 1px solid var(--gac-border-color);
    flex-wrap: wrap;
}

.gac-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    color: var(--gac-text-secondary);
}

.gac-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.gac-legend-dot.morning {
    background: var(--gac-morning-color);
}

.gac-legend-dot.afternoon {
    background: var(--gac-afternoon-color);
}

/* ========================================
   Calendar Grid
   ======================================== */
.gac-calendar-grid {
    padding: 12px;
    background: var(--gac-bg-primary);
}

.gac-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 8px;
}

.gac-weekday {
    text-align: center;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--gac-text-muted);
    padding: 8px 2px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.gac-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

/* ========================================
   Day Cells
   ======================================== */
.gac-day {
    background: var(--gac-bg-primary);
    border: 1px solid var(--gac-border-color);
    border-radius: 8px;
    padding: 6px 4px;
    min-height: 70px;
    display: flex;
    flex-direction: column;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.gac-day.empty {
    background: var(--gac-bg-secondary);
    border-color: transparent;
    min-height: 0;
    padding: 6px 4px;
}

.gac-day.today {
    border-color: var(--gac-primary-color);
    border-width: 2px;
    background: var(--gac-bg-secondary);
}

.gac-day.has-availability {
    cursor: pointer;
}

.gac-day.has-availability:hover {
    background: var(--gac-bg-secondary);
    transform: translateY(-1px);
    box-shadow: var(--gac-shadow);
}

.gac-day.has-availability:active {
    transform: translateY(0);
}

.gac-day-number {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--gac-text-primary);
    margin-bottom: 4px;
    text-align: center;
}

.gac-day.empty .gac-day-number {
    color: var(--gac-text-muted);
}

.gac-day.today .gac-day-number {
    color: var(--gac-primary-color);
}

/* ========================================
   Availability Badges
   ======================================== */
.gac-availability-badges {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: auto;
}

.gac-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 22px;
    -webkit-tap-highlight-color: transparent;
}

.gac-badge:active {
    transform: scale(0.95);
    opacity: 0.8;
}

.gac-badge.morning {
    background: var(--gac-morning-bg);
    color: var(--gac-morning-text);
}

.gac-badge.afternoon {
    background: var(--gac-afternoon-bg);
    color: var(--gac-afternoon-text);
}

.gac-badge-icon {
    font-size: 0.625rem;
    line-height: 1;
}

.gac-badge-count {
    font-weight: 700;
    font-size: 0.75rem;
}

/* ========================================
   Loading State
   ======================================== */
.gac-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gac-bg-primary);
    opacity: 0.95;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 10;
    color: var(--gac-text-secondary);
}

.gac-loading.hidden {
    display: none;
}

.gac-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--gac-border-color);
    border-top-color: var(--gac-primary-color);
    border-radius: 50%;
    animation: gac-spin 0.8s linear infinite;
}

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

/* ========================================
   Modal Overlay
   ======================================== */
.gac-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    padding: 16px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.gac-modal {
    background: var(--gac-bg-primary);
    border-radius: 16px;
    width: 100%;
    max-width: 420px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: var(--gac-shadow-lg);
    animation: gac-modal-in 0.3s ease;
    display: flex;
    flex-direction: column;
}

@keyframes gac-modal-in {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.gac-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--gac-primary-color);
    color: #fff;
    gap: 12px;
    flex-shrink: 0;
}

.gac-modal-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
}

.gac-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    min-width: 36px;
    font-size: 22px;
    cursor: pointer;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}

.gac-modal-close:hover,
.gac-modal-close:active {
    background: rgba(255, 255, 255, 0.3);
}

.gac-modal-body {
    padding: 0;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

.gac-modal-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.gac-modal-loading.hidden {
    display: none;
}

/* ========================================
   Guides List in Modal
   ======================================== */
.gac-guides-list {
    padding: 0;
}

.gac-guide-card {
    display: flex;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--gac-border-color);
    transition: background 0.2s ease;
}

.gac-guide-card:last-child {
    border-bottom: none;
}

.gac-guide-card:active {
    background: var(--gac-bg-secondary);
}

.gac-guide-photo {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--gac-bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.gac-guide-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gac-guide-photo-placeholder {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gac-primary-color), #6366f1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    font-weight: 600;
}

.gac-guide-info {
    flex: 1;
    min-width: 0;
}

.gac-guide-name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--gac-text-primary);
    margin: 0 0 6px 0;
}

.gac-guide-slots {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.gac-guide-slot {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.6875rem;
    font-weight: 500;
}

.gac-guide-slot.morning {
    background: var(--gac-morning-bg);
    color: var(--gac-morning-text);
}

.gac-guide-slot.afternoon {
    background: var(--gac-afternoon-bg);
    color: var(--gac-afternoon-text);
}

.gac-guide-slot.allday {
    background: linear-gradient(135deg, var(--gac-morning-bg), var(--gac-afternoon-bg));
    color: var(--gac-text-primary);
}

.gac-guide-details {
    font-size: 0.75rem;
    color: var(--gac-text-secondary);
}

.gac-guide-details p {
    margin: 4px 0;
    display: flex;
    align-items: flex-start;
    gap: 4px;
    line-height: 1.4;
    flex-wrap: wrap;
}

.gac-guide-details strong {
    color: var(--gac-text-primary);
    font-weight: 500;
}

.gac-guide-details a {
    color: var(--gac-primary-color);
    text-decoration: none;
    word-break: break-all;
}

.gac-guide-details a:hover {
    text-decoration: underline;
}

.gac-no-guides {
    text-align: center;
    padding: 40px 20px;
    color: var(--gac-text-muted);
}

.gac-no-guides-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* ========================================
   Info Button
   ======================================== */
.gac-info-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 10px;
    padding: 8px 14px;
    background: var(--gac-primary-color);
    color: #fff !important;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none !important;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.gac-info-button:hover {
    background: var(--gac-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(55, 136, 216, 0.3);
}

.gac-info-button:active {
    transform: translateY(0);
}

/* ========================================
   Responsive - Tablet
   ======================================== */
@media (min-width: 481px) and (max-width: 768px) {
    .gac-public-calendar-wrapper {
        border-radius: 12px;
    }
    
    .gac-day {
        min-height: 80px;
        padding: 8px 6px;
    }
    
    .gac-day-number {
        font-size: 0.875rem;
    }
    
    .gac-badge {
        padding: 5px 8px;
        font-size: 0.75rem;
    }
}

/* ========================================
   Responsive - Desktop
   ======================================== */
@media (min-width: 769px) {
    .gac-calendar-header {
        padding: 20px 24px;
    }
    
    .gac-month-title {
        font-size: 1.5rem;
    }
    
    .gac-calendar-grid {
        padding: 16px;
    }
    
    .gac-weekday {
        font-size: 0.75rem;
        padding: 10px 4px;
    }
    
    .gac-days {
        gap: 6px;
    }
    
    .gac-day {
        min-height: 90px;
        padding: 8px;
        border-radius: 10px;
    }
    
    .gac-day-number {
        font-size: 0.9375rem;
    }
    
    .gac-badge {
        padding: 5px 10px;
        font-size: 0.75rem;
        border-radius: 6px;
    }
    
    .gac-badge:hover {
        transform: scale(1.05);
    }
    
    .gac-badge-icon {
        font-size: 0.6875rem;
    }
    
    .gac-modal {
        max-width: 500px;
    }
    
    .gac-modal-header {
        padding: 20px 24px;
    }
    
    .gac-modal-title {
        font-size: 1.125rem;
    }
    
    .gac-guide-card {
        padding: 20px 24px;
        gap: 16px;
    }
    
    .gac-guide-card:hover {
        background: var(--gac-bg-secondary);
    }
    
    .gac-guide-photo,
    .gac-guide-photo-placeholder {
        width: 60px;
        height: 60px;
        font-size: 1.25rem;
    }
    
    .gac-guide-name {
        font-size: 1rem;
    }
    
    .gac-guide-details {
        font-size: 0.8125rem;
    }
}

/* ========================================
   Responsive - Small Mobile
   ======================================== */
@media (max-width: 380px) {
    .gac-calendar-header {
        padding: 12px 14px;
    }
    
    .gac-month-title {
        font-size: 1rem;
    }
    
    .gac-nav-btn {
        min-width: 36px;
        min-height: 36px;
        padding: 6px;
    }
    
    .gac-legend {
        gap: 12px;
        padding: 10px 12px;
    }
    
    .gac-legend-item {
        font-size: 0.75rem;
    }
    
    .gac-calendar-grid {
        padding: 8px;
    }
    
    .gac-weekday {
        font-size: 0.5625rem;
        padding: 6px 1px;
    }
    
    .gac-days {
        gap: 3px;
    }
    
    .gac-day {
        min-height: 58px;
        padding: 4px 3px;
        border-radius: 6px;
    }
    
    .gac-day-number {
        font-size: 0.6875rem;
        margin-bottom: 2px;
    }
    
    .gac-availability-badges {
        gap: 2px;
    }
    
    .gac-badge {
        padding: 3px 4px;
        font-size: 0.5625rem;
        border-radius: 3px;
        min-height: 18px;
    }
    
    .gac-badge-icon {
        font-size: 0.5rem;
    }
    
    .gac-badge-count {
        font-size: 0.625rem;
    }
    
    .gac-modal-overlay {
        padding: 10px;
    }
    
    .gac-modal-header {
        padding: 14px 16px;
    }
    
    .gac-modal-title {
        font-size: 0.9375rem;
    }
    
    .gac-guide-card {
        padding: 14px;
        gap: 10px;
    }
    
    .gac-guide-photo,
    .gac-guide-photo-placeholder {
        width: 44px;
        height: 44px;
        font-size: 1rem;
    }
    
    .gac-guide-name {
        font-size: 0.875rem;
    }
    
    .gac-guide-slot {
        font-size: 0.625rem;
        padding: 2px 6px;
    }
    
    .gac-guide-details {
        font-size: 0.6875rem;
    }
}

/* ========================================
   Touch Device Optimizations
   ======================================== */
@media (hover: none) and (pointer: coarse) {
    .gac-day.has-availability:hover {
        transform: none;
        box-shadow: none;
        background: var(--gac-bg-primary);
    }
    
    .gac-badge:hover {
        transform: none;
    }
    
    .gac-nav-btn:hover {
        background: rgba(255, 255, 255, 0.2);
    }
    
    .gac-guide-card:hover {
        background: transparent;
    }
}

/* ========================================
   Safe Area for iPhone X+ and notched devices
   ======================================== */
@supports (padding: max(0px)) {
    .gac-modal-overlay {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
    .gac-public-calendar-wrapper {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .gac-nav-btn {
        display: none;
    }
    
    .gac-modal-overlay {
        display: none !important;
    }
}
