/**
 * Modern Bus Booking, Interactive Grid Layout & Seat Customizer CSS
 * Satyam Education Exam Bus Service
 */

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --success: #10b981;
    --success-dark: #059669;
    --warning: #f59e0b;
    --danger: #ef4444;
    --sleeper-color: #0284c7;
    --sleeper-dark: #0369a1;
    --dark: #0f172a;
    --gray-bg: #f8fafc;
    --border-color: #e2e8f0;
    --bus-body: #1e293b;
    --bus-interior: #f1f5f9;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, #f0f4f8 0%, #e2e8f0 100%);
    color: #1e293b;
    min-height: 100vh;
    line-height: 1.5;
}

/* Bus Container & Chassis Frame */
.bus-chassis {
    position: relative;
    background: #ffffff;
    border: 3px solid #cbd5e1;
    border-radius: 40px 40px 24px 24px;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    padding: 24px 20px;
    margin: 0 auto;
    max-width: 760px;
    overflow: hidden;
    animation: busDriveIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes busDriveIn {
    0% {
        opacity: 0;
        transform: translateY(35px) scale(0.97);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Bus Front & Windshield */
.bus-front-cabin {
    position: relative;
    background: linear-gradient(180deg, #1e293b 0%, #334155 100%);
    border-radius: 28px 28px 14px 14px;
    padding: 16px 20px;
    margin-bottom: 22px;
    color: white;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.2), 0 4px 12px rgba(15, 23, 42, 0.2);
}

.windshield-glass {
    height: 18px;
    background: linear-gradient(135deg, rgba(255,255,255,0.4) 0%, rgba(56, 189, 248, 0.2) 50%, rgba(255,255,255,0.1) 100%);
    border-radius: 12px;
    margin-bottom: 12px;
    position: relative;
    overflow: hidden;
}

.windshield-glass::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
    animation: wiperReflection 4s infinite linear;
}

@keyframes wiperReflection {
    0% { left: -100%; }
    50% { left: 150%; }
    100% { left: 150%; }
}

.bus-cockpit {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Cockpit positioning: Driver Left vs Right */
.bus-cockpit.driver-right {
    flex-direction: row;
}

.bus-cockpit.driver-left {
    flex-direction: row-reverse;
}

.driver-seat-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 6px 14px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 700;
}

.steering-wheel {
    width: 30px;
    height: 30px;
    border: 3px solid #f8fafc;
    border-radius: 50%;
    position: relative;
    animation: steerRotate 5s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
}

.steering-wheel::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 3px;
    background: #f8fafc;
}

.steering-wheel::after {
    content: '';
    position: absolute;
    width: 3px;
    height: 50%;
    bottom: 0;
    background: #f8fafc;
}

@keyframes steerRotate {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(18deg); }
    50% { transform: rotate(0deg); }
    75% { transform: rotate(-18deg); }
}

.bus-door-badge {
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid #10b981;
    color: #34d399;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.bus-door-badge::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
}

/* Deck Switcher Tabs */
.deck-switcher {
    display: flex;
    gap: 8px;
    background: #f1f5f9;
    padding: 6px;
    border-radius: 14px;
    margin-bottom: 20px;
}

.deck-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    background: transparent;
    color: #64748b;
    transition: all 0.25s ease;
}

.deck-tab.active {
    background: #ffffff;
    color: #1e293b;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
}

.bus-floor {
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: 20px;
    padding: 18px 12px;
    position: relative;
}

/* Row & Column Layout */
.bus-grid-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 12px;
    position: relative;
}

.row-index-indicator {
    width: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #94a3b8;
    text-align: center;
    flex-shrink: 0;
}

/* Individual Seat Styling - Regular Seater */
.bus-seat {
    position: relative;
    width: 50px;
    height: 52px;
    border-radius: 10px 10px 8px 8px;
    background: #ffffff;
    border: 2px solid #cbd5e1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    user-select: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.bus-seat::before {
    /* Headrest */
    content: '';
    position: absolute;
    top: -5px;
    width: 26px;
    height: 6px;
    border-radius: 4px;
    background: inherit;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.bus-seat::after {
    /* Seat cushion line */
    content: '';
    position: absolute;
    bottom: 4px;
    width: 34px;
    height: 8px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.05);
}

.bus-seat .seat-id {
    font-size: 0.82rem;
    font-weight: 800;
    line-height: 1;
    z-index: 2;
}

.bus-seat .seat-fare {
    font-size: 0.62rem;
    font-weight: 600;
    opacity: 0.85;
    margin-top: 2px;
    z-index: 2;
}

/* Single Sleeper Berth */
.bus-seat.sleeper, .bus-seat.sleeper_single {
    width: 66px;
    height: 100px;
    border-radius: 12px;
}

.bus-seat.sleeper::before, .bus-seat.sleeper_single::before {
    /* Pillow */
    content: '';
    position: absolute;
    top: 6px;
    width: 44px;
    height: 18px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.bus-seat.sleeper::after, .bus-seat.sleeper_single::after {
    /* Blanket Fold */
    content: '';
    position: absolute;
    bottom: 6px;
    width: 52px;
    height: 36px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.04);
    border-top: 1px dashed rgba(0, 0, 0, 0.1);
}

/* Double Sleeper Berth (2 Students in 1 Sleeper Berth) */
.double-sleeper-berth {
    position: relative;
    width: 128px;
    height: 100px;
    background: #f0f9ff;
    border: 2px solid #0284c7;
    border-radius: 14px;
    display: flex;
    padding: 6px;
    gap: 6px;
    box-shadow: 0 4px 6px -1px rgba(2, 132, 199, 0.1);
}

.double-sleeper-berth .berth-title-tag {
    position: absolute;
    top: -9px;
    left: 50%;
    transform: translateX(-50%);
    background: #0284c7;
    color: white;
    font-size: 0.62rem;
    font-weight: 800;
    padding: 1px 8px;
    border-radius: 10px;
    white-space: nowrap;
    letter-spacing: 0.3px;
    z-index: 5;
}

.double-sleeper-slot {
    flex: 1;
    border-radius: 8px;
    background: white;
    border: 1.5px dashed #38bdf8;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    user-select: none;
}

.double-sleeper-slot::before {
    /* Individual mini-pillow */
    content: '';
    position: absolute;
    top: 4px;
    width: 32px;
    height: 12px;
    border-radius: 4px;
    background: #e0f2fe;
    border: 1px solid #bae6fd;
}

.double-sleeper-slot:hover {
    background: #e0f2fe;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(2, 132, 199, 0.25);
}

/* Seat States (Available, Selected, Booked, Blocked) */
.bus-seat.available, .double-sleeper-slot.available {
    background: #ecfdf5;
    border-color: #10b981;
    color: #065f46;
}

.bus-seat.available:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 8px 16px -2px rgba(16, 185, 129, 0.35);
    background: #d1fae5;
    border-color: #059669;
}

.bus-seat.selected, .double-sleeper-slot.selected {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
    border-color: #b45309 !important;
    color: #ffffff !important;
    transform: translateY(-4px) scale(1.06);
    box-shadow: 0 10px 20px -3px rgba(217, 119, 6, 0.45);
    animation: selectedPulse 1.8s infinite;
}

@keyframes selectedPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
    50% { box-shadow: 0 0 0 8px rgba(245, 158, 11, 0); }
}

.bus-seat.booked, .double-sleeper-slot.booked {
    background: #fee2e2 !important;
    border-color: #fca5a5 !important;
    color: #991b1b !important;
    cursor: not-allowed;
    opacity: 0.9;
}

.bus-seat.booked.female, .double-sleeper-slot.booked.female {
    background: #fdf2f8 !important;
    border-color: #f472b6 !important;
    color: #9d174d !important;
}

.bus-seat.blocked, .double-sleeper-slot.blocked {
    background: #f1f5f9 !important;
    border-color: #cbd5e1 !important;
    color: #94a3b8 !important;
    cursor: not-allowed;
}

/* Empty Cell / Walkway / Removed Seat */
.bus-cell-empty {
    width: 50px;
    height: 52px;
    border: 1.5px dashed #e2e8f0;
    border-radius: 8px;
    background: rgba(248, 250, 252, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #cbd5e1;
    font-size: 0.7rem;
}

/* Aisle / Center Walking Path */
.bus-aisle-cell {
    width: 34px;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.bus-aisle-cell::after {
    content: '';
    position: absolute;
    width: 2px;
    height: 100%;
    background: repeating-linear-gradient(to bottom, #cbd5e1 0, #cbd5e1 4px, transparent 4px, transparent 8px);
}

/* Legend Styling */
.seat-legend-box {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 14px 20px;
    margin-bottom: 24px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}

.legend-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
}

.legend-dot {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    border: 2px solid;
}

.legend-dot.seater-avail { background: #ecfdf5; border-color: #10b981; }
.legend-dot.sleeper-avail { background: #f0f9ff; border-color: #0284c7; }
.legend-dot.selected { background: #f59e0b; border-color: #d97706; }
.legend-dot.booked-male { background: #fee2e2; border-color: #fca5a5; }
.legend-dot.booked-female { background: #fdf2f8; border-color: #f472b6; }

/* Sticky Selection & Price Summary Floating Bar */
.floating-booking-bar {
    position: sticky;
    bottom: 20px;
    z-index: 50;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    color: white;
    padding: 16px 24px;
    border-radius: 20px;
    box-shadow: 0 20px 30px -5px rgba(15, 23, 42, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px auto 0;
    max-width: 760px;
    animation: barSlideUp 0.3s ease-out;
}

@keyframes barSlideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.price-display-num {
    font-size: 1.5rem;
    font-weight: 800;
    color: #38bdf8;
    line-height: 1.1;
}

.btn-proceed {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    font-size: 1rem;
    font-weight: 700;
    padding: 12px 28px;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-proceed:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.55);
}

/* Modal Windows */
.custom-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.custom-modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-content-card {
    background: #ffffff;
    border-radius: 24px;
    width: 100%;
    max-width: 620px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    padding: 28px;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.custom-modal-overlay.open .modal-content-card {
    transform: scale(1) translateY(0);
}

.qr-frame {
    position: relative;
    display: inline-block;
    padding: 12px;
    background: #ffffff;
    border: 3px solid #6366f1;
    border-radius: 20px;
    box-shadow: 0 10px 25px -5px rgba(99, 102, 241, 0.25);
}

.upi-apps-row {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.upi-app-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #1e293b;
    text-decoration: none;
    transition: all 0.2s ease;
}

.upi-app-btn:hover {
    background: #eef2ff;
    border-color: #6366f1;
    color: #4338ca;
    transform: translateY(-2px);
}

/* Boarding Pass / Ticket */
.bus-ticket-pass {
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
    overflow: hidden;
    position: relative;
}

.ticket-header-gradient {
    background: linear-gradient(135deg, #1e1b4b 0%, #4338ca 100%);
    color: white;
    padding: 24px;
    position: relative;
}

.ticket-perforation {
    position: relative;
    height: 24px;
    background: #f8fafc;
    border-top: 2px dashed #cbd5e1;
}

.ticket-perforation::before, .ticket-perforation::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #f0f4f8;
    top: -12px;
}

.ticket-perforation::before { left: -12px; }
.ticket-perforation::after { right: -12px; }

/* Admin Interactive Layout Builder Editor */
.editor-toolbar {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 12px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 18px;
}

.tool-palette-btn {
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    border: 1px solid #cbd5e1;
    background: white;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.tool-palette-btn:hover {
    border-color: #4f46e5;
    color: #4f46e5;
    background: #eef2ff;
}

.editable-grid-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 10px;
    margin-bottom: 8px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    transition: background 0.2s;
}

.editable-grid-row:hover {
    background: #f8fafc;
}

.row-drag-handle {
    cursor: grab;
    color: #94a3b8;
    font-size: 1rem;
    padding: 4px;
}

.row-actions-btn {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
}

.row-actions-btn:hover {
    background: #fee2e2;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .bus-chassis {
        padding: 14px 8px;
        border-radius: 20px;
    }
    .bus-seat {
        width: 44px;
        height: 48px;
    }
    .double-sleeper-berth {
        width: 108px;
        height: 88px;
    }
    .bus-seat.sleeper, .bus-seat.sleeper_single {
        width: 54px;
        height: 88px;
    }
    .floating-booking-bar {
        padding: 12px 16px;
        border-radius: 16px;
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    .btn-proceed {
        width: 100%;
        justify-content: center;
    }
}


/* Processing / Payment in Progress Seat State (Orange Pulsing) */
.bus-seat.processing, .double-sleeper-slot.processing {
    background: #ffedd5 !important;
    border-color: #f97316 !important;
    color: #c2410c !important;
    cursor: not-allowed;
    animation: processingPulse 2s infinite ease-in-out;
}

@keyframes processingPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.5);
    }
    50% {
        box-shadow: 0 0 0 7px rgba(249, 115, 22, 0);
        background: #fed7aa !important;
    }
}

.legend-dot.processing {
    background: #f97316;
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.25);
}