/**
 * Tennis Réservation - Public Styles v2.0
 * Mobile-first / Palette terre battue
 */

:root {
    --tr-primary: #c45c35;
    --tr-primary-dark: #a34525;
    --tr-primary-light: #fff5f0;
    --tr-secondary: #8B4513;
    --tr-cream: #f8f5f0;
    --tr-success: #16a34a;
    --tr-success-light: #dcfce7;
    --tr-danger: #dc2626;
    --tr-danger-light: #fef2f2;
    --tr-warning: #d97706;
    --tr-white: #ffffff;
    --tr-border: #e2e0db;
    --tr-border-light: #f0ede7;
    --tr-text: #1a1a17;
    --tr-text-light: #71706b;
    --tr-text-muted: #a3a19b;
    --tr-shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --tr-shadow: 0 2px 8px rgba(0,0,0,0.08);
    --tr-shadow-md: 0 4px 16px rgba(0,0,0,0.1);
    --tr-radius: 10px;
    --tr-radius-lg: 14px;
    --tr-radius-xl: 20px;
    --tr-transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --tr-font: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ===== RESET & BASE ===== */
.tr-reservation-container {
    max-width: 820px;
    margin: 0 auto;
    padding: 12px;
    font-family: var(--tr-font);
    color: var(--tr-text);
    -webkit-font-smoothing: antialiased;
}
.tr-reservation-container * { box-sizing: border-box; margin: 0; padding: 0; }

/* ===== HEADER ===== */
.tr-header {
    background: linear-gradient(135deg, var(--tr-primary) 0%, var(--tr-primary-dark) 100%);
    border-radius: var(--tr-radius-xl);
    padding: 20px;
    margin-bottom: 12px;
    color: white;
    position: relative;
    overflow: hidden;
}
.tr-header::before {
    content: '';
    position: absolute;
    top: -50%; right: -20%;
    width: 200px; height: 200px;
    background: rgba(255,255,255,0.08);
    border-radius: 50%;
}
.tr-header-content {
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
    z-index: 1;
}
.tr-header-icon { font-size: 32px; flex-shrink: 0; }
.tr-header h2 { font-size: 18px; font-weight: 700; margin-bottom: 2px; letter-spacing: -0.3px; }
.tr-header p { font-size: 13px; opacity: 0.85; }

/* ===== PROGRESS STEPS ===== */
.tr-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    padding: 0 8px;
}
.tr-progress-step {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--tr-white);
    border: 2px solid var(--tr-border);
    border-radius: 50px;
    font-size: 12px;
    font-weight: 600;
    color: var(--tr-text-muted);
    transition: var(--tr-transition);
    white-space: nowrap;
}
.tr-progress-step .step-num {
    width: 22px; height: 22px;
    background: var(--tr-border);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 11px; flex-shrink: 0;
}
.tr-progress-step.active { border-color: var(--tr-primary); background: var(--tr-primary-light); color: var(--tr-primary); }
.tr-progress-step.active .step-num { background: var(--tr-primary); color: white; }
.tr-progress-step.done { border-color: var(--tr-success); background: var(--tr-success-light); color: var(--tr-success); }
.tr-progress-step.done .step-num { background: var(--tr-success); color: white; }
.tr-progress-line { width: 20px; height: 2px; background: var(--tr-border); flex-shrink: 0; }
.tr-progress-step .step-label { display: none; }

/* ===== MAIN ===== */
.tr-main {
    background: var(--tr-white);
    border-radius: var(--tr-radius-xl);
    padding: 20px 16px;
    box-shadow: var(--tr-shadow-md);
    border: 1px solid var(--tr-border-light);
}

/* ===== STEPS ===== */
.tr-step-section { display: none; }
.tr-step-section.active { display: block; animation: trFadeIn 0.25s ease; }
@keyframes trFadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.tr-step-title { font-size: 18px; font-weight: 700; color: var(--tr-text); text-align: center; margin-bottom: 20px; }

/* ===== COMPLEXE CARDS ===== */
.tr-cards-grid { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.tr-card {
    display: flex; align-items: center; gap: 14px; padding: 14px;
    border: 2px solid var(--tr-border); border-radius: var(--tr-radius-lg);
    cursor: pointer; transition: var(--tr-transition); background: var(--tr-white);
    -webkit-tap-highlight-color: transparent;
}
.tr-card:active { transform: scale(0.98); }
.tr-card:hover { border-color: var(--tr-primary); background: var(--tr-primary-light); }
.tr-card.selected { border-color: var(--tr-primary); background: var(--tr-primary-light); box-shadow: 0 0 0 3px rgba(196, 92, 53, 0.2); }
.tr-card-image { width: 70px; height: 56px; border-radius: 8px; overflow: hidden; flex-shrink: 0; background: var(--tr-cream); display: flex; align-items: center; justify-content: center; }
.tr-card-image img { width: 100%; height: 100%; object-fit: cover; }
.tr-card-image .tr-card-icon { font-size: 28px; }
.tr-card-content { flex: 1; min-width: 0; }
.tr-card-title { font-weight: 700; color: var(--tr-text); font-size: 15px; margin-bottom: 2px; }
.tr-card-subtitle { font-size: 12px; color: var(--tr-text-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-card-badge { padding: 4px 10px; border-radius: 50px; font-size: 11px; font-weight: 700; flex-shrink: 0; text-transform: uppercase; letter-spacing: 0.3px; }
.tr-card-badge.interieur { background: #dbeafe; color: #1e40af; }
.tr-card-badge.exterieur { background: #d1fae5; color: #065f46; }

/* ===== SERVICE CARDS ===== */
.tr-service-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.tr-service-card {
    padding: 16px 12px; border: 2px solid var(--tr-border); border-radius: var(--tr-radius-lg);
    cursor: pointer; transition: var(--tr-transition); text-align: center; background: var(--tr-white);
    -webkit-tap-highlight-color: transparent;
}
.tr-service-card:active { transform: scale(0.97); }
.tr-service-card:hover { border-color: var(--tr-primary); }
.tr-service-card.selected { border-color: var(--tr-primary); background: var(--tr-primary-light); box-shadow: 0 0 0 3px rgba(196, 92, 53, 0.2); }
.tr-service-card .service-name { font-size: 16px; font-weight: 700; color: var(--tr-text); margin-bottom: 2px; }
.tr-service-card .service-duration { font-size: 11px; color: var(--tr-text-muted); margin-bottom: 8px; }
.tr-service-card .service-price { font-size: 20px; font-weight: 800; color: var(--tr-primary); }
.tr-service-card .service-days { display: flex; gap: 2px; margin-top: 8px; flex-wrap: wrap; justify-content: center; }
.tr-service-card .day-badge { padding: 2px 4px; border-radius: 3px; font-size: 9px; font-weight: 700; background: var(--tr-border-light); color: var(--tr-text-muted); }
.tr-service-card .day-badge.actif { background: var(--tr-primary); color: white; }
.tr-service-card.service-unavailable { pointer-events: none; opacity: 0.35; }

/* ===== CALENDAR ===== */
.tr-calendar { background: var(--tr-white); border: 2px solid var(--tr-border); border-radius: 14px; overflow: hidden; margin-bottom: 20px; }
.tr-cal-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; background: var(--tr-primary); }
.tr-cal-month { font-size: 16px; font-weight: 700; color: #fff; text-transform: capitalize; }
.tr-cal-nav { background: rgba(255,255,255,0.15); border: none; color: #fff; width: 36px; height: 36px; border-radius: 50%; font-size: 20px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 0.2s; }
.tr-cal-nav:hover { background: rgba(255,255,255,0.3); }
.tr-cal-nav:disabled { opacity: 0.3; cursor: not-allowed; }
.tr-cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; padding: 10px 8px 6px; border-bottom: 1px solid var(--tr-border); }
.tr-cal-weekdays span { font-size: 11px; font-weight: 700; color: var(--tr-text-light); text-transform: uppercase; }
.tr-cal-days { display: grid; grid-template-columns: repeat(7, 1fr); padding: 8px; gap: 4px; }
.tr-cal-day { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; border-radius: 10px; cursor: pointer; transition: all 0.2s; color: var(--tr-text); position: relative; }
.tr-cal-day:hover:not(.disabled):not(.empty) { background: var(--tr-primary-light); }
.tr-cal-day.today { box-shadow: inset 0 0 0 2px var(--tr-primary); }
.tr-cal-day.selected { background: var(--tr-primary); color: #fff; box-shadow: 0 2px 8px rgba(196, 92, 53, 0.35); }
.tr-cal-day.disabled { color: var(--tr-text-muted); cursor: not-allowed; opacity: 0.35; }
.tr-cal-day.empty { cursor: default; }
.tr-cal-day.weekend { color: var(--tr-primary); }
.tr-cal-summary { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--tr-primary-light); border: 2px solid var(--tr-primary); border-radius: 10px; margin-bottom: 16px; }
.tr-cal-summary-date { font-weight: 700; font-size: 15px; color: var(--tr-text); }
.tr-cal-change { background: none; border: 1px solid var(--tr-primary); color: var(--tr-primary); padding: 6px 14px; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.tr-cal-change:hover { background: var(--tr-primary); color: #fff; }
.tr-field-label { display: block; font-weight: 700; color: var(--tr-text); margin-bottom: 8px; font-size: 14px; }

/* ===== COURTS ===== */
.tr-courts-section { margin-bottom: 20px; }
.tr-courts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tr-court-card {
    padding: 0; border: 2px solid var(--tr-border); border-radius: var(--tr-radius);
    cursor: pointer; transition: var(--tr-transition); text-align: center; background: var(--tr-white);
    -webkit-tap-highlight-color: transparent; overflow: hidden;
}
.tr-court-card:active { transform: scale(0.97); }
.tr-court-card:hover { border-color: var(--tr-primary); }
.tr-court-card.selected { border-color: var(--tr-primary); background: var(--tr-primary-light); box-shadow: 0 0 0 3px rgba(196, 92, 53, 0.2); }
.tr-court-card .tr-court-img { width: 100%; height: 90px; overflow: hidden; }
.tr-court-card .tr-court-img img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.3s ease; }
.tr-court-card:hover .tr-court-img img { transform: scale(1.05); }
.tr-court-card .court-name { font-weight: 700; color: var(--tr-text); font-size: 14px; padding: 10px 10px 2px; }
.tr-court-card .court-surface { font-size: 11px; color: var(--tr-text-light); padding: 0 10px; }
.tr-court-card .court-light { font-size: 11px; color: var(--tr-warning); padding: 2px 10px 10px; }

/* ===== TIME SLOTS ===== */
.tr-slots-section { margin-top: 20px; }
.tr-slots-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tr-slot {
    padding: 12px 8px; border: 2px solid var(--tr-border); border-radius: var(--tr-radius);
    cursor: pointer; transition: var(--tr-transition); text-align: center; background: var(--tr-white);
    -webkit-tap-highlight-color: transparent;
}
.tr-slot:active:not(.unavailable) { transform: scale(0.95); }
.tr-slot:hover:not(.unavailable) { border-color: var(--tr-primary); background: var(--tr-primary-light); }
.tr-slot.selected { border-color: var(--tr-primary); background: var(--tr-primary); }
.tr-slot.selected .slot-start, .tr-slot.selected .slot-end { color: white !important; }
.tr-slot.unavailable { background: var(--tr-cream); border-color: var(--tr-border-light); cursor: not-allowed; opacity: 0.45; }
.tr-slot.unavailable .slot-start, .tr-slot.unavailable .slot-end { color: var(--tr-text-muted) !important; text-decoration: line-through; }
.tr-slot .slot-start { font-weight: 700; color: var(--tr-text); font-size: 14px; }
.tr-slot .slot-end { font-size: 11px; color: var(--tr-text-light); margin-top: 1px; }
.tr-slot .slot-price { font-size: 11px; font-weight: 700; color: var(--tr-primary); margin-top: 2px; }
.tr-slot.selected .slot-price { color: #fff; }

.tr-slots-legend { display: flex; gap: 14px; margin-top: 12px; font-size: 12px; color: var(--tr-text-light); justify-content: center; flex-wrap: wrap; }
.tr-legend-item { display: flex; align-items: center; gap: 5px; }
.tr-legend-box { width: 14px; height: 14px; border-radius: 4px; border: 2px solid; }
.tr-legend-box.available { background: var(--tr-white); border-color: var(--tr-border); }
.tr-legend-box.selected { background: var(--tr-primary); border-color: var(--tr-primary); }
.tr-legend-box.unavailable { background: var(--tr-cream); border-color: var(--tr-border-light); }

/* ===== CLIENT FORM ===== */
.tr-client-form { display: flex; flex-direction: column; gap: 14px; }
.tr-form-group { display: flex; flex-direction: column; gap: 5px; }
.tr-form-group label { font-weight: 600; color: var(--tr-text); font-size: 13px; }
.tr-form-group label .required { color: var(--tr-danger); }
.tr-form-group input {
    padding: 12px 14px; border: 2px solid var(--tr-border); border-radius: var(--tr-radius);
    font-size: 16px; transition: var(--tr-transition); width: 100%; font-family: inherit;
    background: var(--tr-white); -webkit-appearance: none;
}
.tr-form-group input:focus { outline: none; border-color: var(--tr-primary); box-shadow: 0 0 0 3px rgba(196, 92, 53, 0.1); }

/* ===== SUMMARY ===== */
.tr-summary-box { background: var(--tr-cream); border-radius: var(--tr-radius-lg); padding: 18px; margin-bottom: 20px; border: 1px solid var(--tr-border-light); }
.tr-summary-title { font-weight: 700; color: var(--tr-text); margin-bottom: 14px; font-size: 15px; }
.tr-summary-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--tr-border-light); font-size: 13px; }
.tr-summary-row:last-of-type { border-bottom: none; }
.tr-summary-row .label { color: var(--tr-text-light); }
.tr-summary-row .value { font-weight: 600; color: var(--tr-text); text-align: right; max-width: 55%; }
.tr-summary-total { display: flex; justify-content: space-between; align-items: center; padding-top: 14px; margin-top: 10px; border-top: 2px solid var(--tr-border); }
.tr-summary-total .label { font-weight: 700; color: var(--tr-text); font-size: 15px; }
.tr-summary-total .value { font-weight: 800; color: var(--tr-primary); font-size: 22px; }

/* ===== BUTTONS ===== */
.tr-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--tr-border-light); }
.tr-btn {
    padding: 12px 20px; border-radius: var(--tr-radius); font-size: 14px; font-weight: 700;
    cursor: pointer; transition: var(--tr-transition); border: none; display: inline-flex;
    align-items: center; gap: 6px; font-family: inherit; -webkit-tap-highlight-color: transparent; white-space: nowrap;
}
.tr-btn:active { transform: scale(0.97); }
.tr-btn-primary { background: var(--tr-primary); color: white; }
.tr-btn-primary:hover { background: var(--tr-primary-dark); }
.tr-btn-secondary { background: var(--tr-white); color: var(--tr-text); border: 2px solid var(--tr-border); }
.tr-btn-secondary:hover { border-color: var(--tr-text-muted); }
.tr-btn-success { background: var(--tr-success); color: white; padding: 14px 24px; font-size: 15px; flex: 1; }
.tr-btn-success:hover { background: #15803d; }
.tr-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ===== SUCCESS ===== */
.tr-success { text-align: center; padding: 30px 16px; }
.tr-success-icon { width: 64px; height: 64px; background: var(--tr-success); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 32px; margin: 0 auto 20px; box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3); }
.tr-success h3 { color: var(--tr-success); font-size: 20px; margin-bottom: 8px; }
.tr-success p { color: var(--tr-text-light); margin-bottom: 20px; font-size: 14px; }
.tr-success-note { font-size: 12px !important; color: var(--tr-text-muted) !important; }
.tr-access-code { display: inline-block; background: var(--tr-cream); padding: 16px 32px; border-radius: var(--tr-radius-lg); margin-bottom: 16px; border: 2px dashed var(--tr-primary); }
.tr-access-code .code-label { font-size: 12px; color: var(--tr-text-light); margin-bottom: 6px; }
.tr-access-code .code-value { font-size: 32px; font-weight: 800; color: var(--tr-primary); letter-spacing: 5px; font-family: 'Courier New', monospace; }

/* ===== LOADING ===== */
.tr-loading { text-align: center; padding: 32px; color: var(--tr-text-light); display: flex; flex-direction: column; align-items: center; gap: 12px; font-size: 14px; }
.tr-spinner { width: 32px; height: 32px; border: 3px solid var(--tr-border); border-top-color: var(--tr-primary); border-radius: 50%; animation: trSpin 0.8s linear infinite; }
.tr-spinner-small { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: trSpin 0.8s linear infinite; display: inline-block; }
@keyframes trSpin { to { transform: rotate(360deg); } }
.tr-error { background: var(--tr-danger-light); border: 1px solid var(--tr-danger); color: var(--tr-danger); padding: 12px 14px; border-radius: var(--tr-radius); margin: 12px 0; font-size: 13px; }
.tr-empty { text-align: center; padding: 32px; color: var(--tr-text-muted); font-size: 14px; }

/* ===== WEATHER ===== */
.tr-weather-widget { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); border-radius: var(--tr-radius-lg); padding: 16px; margin: 16px 0; color: white; box-shadow: var(--tr-shadow); }
.tr-weather-loading { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 16px; font-size: 13px; }
.tr-weather-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.tr-weather-icon { width: 52px; height: 52px; }
.tr-weather-temp { font-size: 2em; font-weight: 800; line-height: 1; }
.tr-weather-temp-min { font-size: 0.45em; opacity: 0.8; }
.tr-weather-condition { font-size: 0.95em; opacity: 0.9; margin-top: 2px; }
.tr-weather-details { display: flex; justify-content: space-around; padding: 12px 0; border-top: 1px solid rgba(255,255,255,0.2); border-bottom: 1px solid rgba(255,255,255,0.2); margin-bottom: 12px; }
.tr-weather-detail { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; }
.tr-weather-detail-icon { font-size: 1.2em; }
.tr-weather-detail-label { opacity: 0.75; font-size: 10px; }
.tr-weather-detail-value { font-weight: 700; font-size: 13px; }
.tr-weather-recommendation { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px; border-radius: var(--tr-radius); background: rgba(255,255,255,0.2); font-size: 13px; }
.tr-weather-recommendation.excellent { background: rgba(16, 185, 129, 0.3); }
.tr-weather-recommendation.good { background: rgba(59, 130, 246, 0.3); }
.tr-weather-recommendation.moderate { background: rgba(245, 158, 11, 0.3); }
.tr-weather-recommendation.poor { background: rgba(239, 68, 68, 0.3); }
.tr-weather-recommendation.bad { background: rgba(220, 38, 38, 0.4); }
.tr-weather-error, .tr-weather-unavailable { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px; background: rgba(255,255,255,0.1); border-radius: var(--tr-radius); font-size: 13px; }

/* ===== RESPONSIVE TABLET (480px+) ===== */
@media (min-width: 480px) {
    .tr-reservation-container { padding: 16px; }
    .tr-header { padding: 24px; }
    .tr-header h2 { font-size: 22px; }
    .tr-header-icon { font-size: 38px; }
    .tr-progress-step .step-label { display: inline; }
    .tr-main { padding: 28px 24px; }
    .tr-step-title { font-size: 20px; }
    .tr-slots-grid { grid-template-columns: repeat(4, 1fr); }
    .tr-courts-grid { grid-template-columns: repeat(3, 1fr); }
    .tr-service-cards { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    .tr-card-image { width: 90px; height: 64px; }
}

/* ===== RESPONSIVE DESKTOP (768px+) ===== */
@media (min-width: 768px) {
    .tr-reservation-container { padding: 20px; }
    .tr-header { padding: 28px 32px; }
    .tr-header h2 { font-size: 24px; }
    .tr-header p { font-size: 14px; }
    .tr-main { padding: 32px; }
    .tr-progress-step { padding: 10px 16px; font-size: 13px; }
    .tr-progress-line { width: 30px; }
    .tr-card { padding: 18px; gap: 18px; }
    .tr-card-image { width: 110px; height: 76px; }
    .tr-card-title { font-size: 17px; }
    .tr-slots-grid { grid-template-columns: repeat(5, 1fr); }
    .tr-client-form { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
    .tr-client-form .tr-form-group:last-child { grid-column: 1 / -1; }
    .tr-btn-success { flex: initial; }
    .tr-calendar { border-radius: 12px; }
}

/* ===== TOUCH FEEDBACK ===== */
@media (hover: none) {
    .tr-card:hover, .tr-service-card:hover, .tr-court-card:hover, .tr-slot:hover:not(.unavailable) { border-color: var(--tr-border); background: var(--tr-white); }
    .tr-card.selected, .tr-service-card.selected, .tr-court-card.selected { border-color: var(--tr-primary); background: var(--tr-primary-light); }
}

/* ===== SAFE AREA ===== */
@supports (padding: env(safe-area-inset-bottom)) {
    .tr-reservation-container { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}
