/* ===================================
   APPOINTMENT CARDS - MOBILE FIRST
   =================================== */

/* Card Container */
.appointment-card {
    position: relative;
    width: 100%;
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 180px;
}

.appointment-card:hover,
.appointment-card:active {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.appointment-card:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Category-specific Card Colors */
.appointment-card.card-work {
    border-left: 4px solid #f97316;
}

.appointment-card.card-personal {
    border-left: 4px solid #10b981;
}

/* Category Badge */
.card-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
}

.card-badge-right {
    left: auto;
    right: 12px;
}

.badge-pill {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Keyword badge used in cards and modal */
.keyword-badge {
    background: #ffc107;
    color: #111;
    padding: 4px 8px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 11px;
    text-transform: none;
}

.keyword-badge--blaaswerk { background: #FFC107; color: #111; }
.keyword-badge--voorwerk { background: #06B6D4; color: #04202A; }
.keyword-badge--schadeherstel { background: #EF4444; color: #fff; }
.keyword-badge--hoogwerker { background: #7C3AED; color: #fff; }

/* Selected marker styling for visual emphasis */
.numbered-marker.selected { box-shadow: 0 4px 12px rgba(0,0,0,0.25); transform: scale(1.08); }

/* Modal keyword variants (same colors for consistency) */
.modal-keyword-badge--blaaswerk { background: #FFC107; color: #111; }
.modal-keyword-badge--voorwerk { background: #06B6D4; color: #04202A; }
.modal-keyword-badge--schadeherstel { background: #EF4444; color: #fff; }
.modal-keyword-badge--hoogwerker { background: #7C3AED; color: #fff; }

.keyword-badge--absolute {
    position: absolute;
    top: 8px;
    right: 12px;
    z-index: 5;
}

/* Modal specific keyword badge (inline inside badges row) */
.modal-keyword-badge {
    background: #ffc107;
    color: #111;
    padding: 4px 8px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 11px;
    text-transform: none;
}

.badge-work {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: white;
}

.badge-personal {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

/* Status Badge (Top-Right, aligned with Category Badge) */

/* Drag Handle */
.drag-handle {
    position: absolute;
    top: 12px;
    right: 50px;
    color: #9ca3af;
    cursor: grab;
    padding: 4px;
    z-index: 3;
}

.drag-handle:active {
    cursor: grabbing;
}

.drag-handle svg {
    display: block;
}

/* Card Content */
.card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 30px;
}

/* Header Row */
.card-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-top: 32px; /* Space for badges at top */
}

.card-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #111827;
    line-height: 1.3;
    flex: 1;
    padding-right: 30px; /* Space for chevron arrow */
}

/* Address */
.card-address {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #6b7280;
    font-size: 14px;
}

.card-address svg {
    flex-shrink: 0;
    color: #9ca3af;
}

/* Distance */
.card-distance {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #f97316;
    font-size: 13px;
    font-weight: 600;
    background: rgba(249, 115, 22, 0.1);
    padding: 4px 10px;
    border-radius: 6px;
    width: fit-content;
}

.card-distance svg {
    flex-shrink: 0;
}

/* Date/Time Chips */

/* Date/Time Row (Bottom with 3 columns) */

/* Chevron Arrow */
.card-chevron {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #d1d5db;
    transition: all 0.3s ease;
}

.appointment-card:hover .card-chevron {
    color: #9ca3af;
    transform: translateY(-50%) translateX(4px);
}

/* ===================================
   CARDS LIST CONTAINER
   =================================== */

.appointments-cards-container {
    width: 100%;
    padding: 0;
}

.appointments-cards-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ===================================
   SORT CONTROLS
   =================================== */

.sort-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
    margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.sort-label {
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
}

.sort-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.sort-btn {
    padding: 6px 14px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.sort-btn:hover {
    background: #e5e7eb;
    color: #111827;
}

.sort-btn.active {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: white;
    border-color: #ea580c;
}

.sort-btn svg {
    width: 12px;
    height: 12px;
    margin-left: 4px;
    transition: transform 0.3s ease;
}

.sort-btn.active.desc svg {
    transform: rotate(180deg);
}

/* ===================================
   APPOINTMENT MODAL
   =================================== */

.appointment-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: flex-end; /* Bottom on mobile */
    justify-content: center;
    animation: fadeIn 0.3s ease;
    overflow-y: auto; /* Allow scrolling if needed */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.appointment-modal {
    width: 100%;
    max-width: 100vw;
    max-height: 92vh; /* Leave room for status bar */
    background: white;
    border-radius: 24px 24px 0 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 0; /* Remove any margins */
}

.modal-handle {
    width: 40px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 12px auto 0;
    flex-shrink: 0;
}

.modal-header {
    position: sticky;
    top: 0;
    background: white;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
    flex-shrink: 0;
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: #111827;
    margin: 0;
    flex: 1;
    padding-right: 12px;
    line-height: 1.3;
}

.modal-close {
    background: #f3f4f6;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.modal-close:hover {
    background: #e5e7eb;
}

.modal-close:active {
    background: #d1d5db;
    transform: scale(0.95);
}

.modal-close svg {
    display: block;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    overscroll-behavior: contain; /* Prevent pull-to-refresh */
    padding-bottom: max(env(safe-area-inset-bottom, 20px), 100px); /* Extra space for buttons + iOS safe area */
}

.modal-section {
    margin-bottom: 20px;
}

.modal-section:last-child {
    margin-bottom: 0;
}

/* Section Variants - Subtle */
.modal-section-badges {
    padding: 12px 0;
}

.modal-section-highlight,
.modal-section-schedule {
    padding: 16px;
    background: white;
    border-radius: 12px;
    border: 1px solid #f3f4f6;
}

/* Card container used inside modal for notes */
.modal-card {
    background: #ffffff;
    border: 1px solid #e8e8ea;
    border-radius: 8px;
    padding: 12px;
    margin-top: 8px;
}

.modal-field-description {
    background: #f5f5f7;
    border-radius: 6px;
    min-height: 48px;
    padding: 10px;
}

.modal-section-actions {
    padding: 20px 0;
}

/* Section Titles - Simple */
.modal-section-title {
    font-size: 12px;
    font-weight: 700;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.modal-section-title svg {
    width: 14px;
    height: 14px;
    opacity: 0.6;
}

/* Alert Sections */
.modal-alert {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 10px;
    color: white;
    margin-bottom: 20px;
}

.modal-alert svg {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

.modal-alert-title {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 2px;
}

.modal-alert-subtitle {
    font-size: 13px;
    opacity: 0.9;
}

.modal-alert-today {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.modal-alert-active {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
    }
    50% {
        box-shadow: 0 6px 16px rgba(249, 115, 22, 0.5);
    }
}

/* Info Rows - Subtle */
.modal-info-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: #f9fafb;
    border-radius: 8px;
    margin-bottom: 8px;
}

.modal-info-row:last-child {
    margin-bottom: 0;
}

/* Highlight only distance with primary color */
.modal-info-row-distance {
    background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
    border-left: 3px solid #f97316;
}

.modal-info-row-duration {
    background: #f9fafb;
}

.modal-info-icon {
    color: #6b7280;
    flex-shrink: 0;
    margin-top: 2px;
}

.modal-info-icon svg {
    display: block;
}

.modal-info-content {
    flex: 1;
}

.modal-info-label {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 4px;
}

.modal-info-value {
    font-size: 15px;
    color: #111827;
    font-weight: 500;
}

.modal-info-value-highlight {
    color: #f97316;
    font-weight: 700;
}

.modal-info-value-code {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #6b7280;
}

/* Modal Action Buttons - 2x2 Grid */
.modal-actions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.modal-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 16px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    white-space: nowrap;
}

.modal-action-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.modal-action-btn span {
    font-size: 14px;
    font-weight: 600;
}

/* Navigate - Primary Orange (Top Left) */
.modal-action-primary {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.3);
}

.modal-action-primary:hover {
    background: linear-gradient(135deg, #ea580c 0%, #c2410c 100%);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
    transform: translateY(-1px);
}

.modal-action-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.3);
}

/* View on Map - Gray (Top Right) */
.modal-action-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #e5e7eb;
}

.modal-action-secondary:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
    transform: translateY(-1px);
}

.modal-action-secondary:active {
    background: #d1d5db;
    transform: translateY(0);
}

/* Edit - Blue (Bottom Left) */
.modal-action-edit {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.modal-action-edit:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    transform: translateY(-1px);
}

.modal-action-edit:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* Delete - Red (Bottom Right) */
.modal-action-delete {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.modal-action-delete:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
    transform: translateY(-1px);
}

.modal-action-delete:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

/* Mobile adjustments - Keep text visible */
@media (max-width: 480px) {
    .modal-action-btn {
        padding: 12px 10px;
        font-size: 13px;
        gap: 6px;
    }
    
    .modal-action-btn svg {
        width: 16px;
        height: 16px;
    }
    
    .modal-action-btn span {
        font-size: 12px; /* Smaller text on mobile but still visible */
    }
}

@media (min-width: 481px) {
    .modal-actions-grid {
        gap: 12px;
    }
    
    .modal-action-btn {
        padding: 14px 18px;
    }
}

/* ===================================
   RESPONSIVE - TABLET & DESKTOP
   =================================== */

@media (min-width: 640px) {
    /* Small tablets and up */
    .appointment-modal-overlay {
        align-items: center; /* Center on tablets */
        padding: 20px;
    }

    .appointment-modal {
        width: 90%;
        max-width: 600px;
        max-height: 85vh;
        border-radius: 16px; /* Rounded corners on all sides */
        margin: auto; /* Center in overlay */
    }

    .modal-handle {
        display: none; /* Hide swipe handle on desktop */
    }

    .modal-header {
        padding: 20px 24px;
    }

    .modal-body {
        padding: 24px;
    }
}

@media (min-width: 768px) {
    /* 2-column grid on tablet */
    .appointments-cards-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .appointment-card {
        margin-bottom: 0;
    }

    .appointment-modal {
        max-width: 650px;
    }

    .modal-title {
        font-size: 22px;
    }

    /* Button grid can be 2 columns on larger screens */
    .modal-actions-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    /* Desktop */
    .appointments-cards-list {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }

    .appointment-modal {
        max-width: 700px;
        max-height: 80vh;
    }

    .modal-header {
        padding: 24px 28px;
    }

    .modal-body {
        padding: 28px;
    }
}

/* Extra small devices - Very careful with viewport height */
@media (max-height: 600px) {
    .appointment-modal {
        max-height: 95vh; /* Use more of the screen on small height devices */
    }

    .modal-header {
        padding: 12px 16px;
    }

    .modal-title {
        font-size: 18px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-section {
        margin-bottom: 16px;
    }
}

/* Landscape mode on phones */
@media (max-height: 500px) and (orientation: landscape) {
    .appointment-modal-overlay {
        align-items: flex-start; /* Align to top in landscape */
        padding-top: 10px;
    }

    .appointment-modal {
        max-height: calc(100vh - 20px);
        border-radius: 16px;
    }

    .modal-handle {
        display: none;
    }
}

/* ===================================
   EMPTY STATE
   =================================== */

.appointments-empty {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    color: #d1d5db;
}

.empty-title {
    font-size: 20px;
    font-weight: 700;
    color: #374151;
    margin-bottom: 8px;
}

.empty-message {
    font-size: 15px;
    color: #6b7280;
    margin-bottom: 24px;
}

.empty-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.empty-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

/* ===================================
   LOADING SKELETON
   =================================== */

.card-skeleton {
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 12px;
    height: 180px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
