/* ================================================
   CSS Variables
   ================================================ */
:root {
    --primary-color: #41826e;
    --primary-dark: #356a5a;
    --primary-light: rgba(65, 130, 110, 0.1);
    --white-color: #ffffff;
    --dark-grey-color: #333333;
    --light-grey-color: #f4f7f6;
    --warning-color: #f39c12;
    --border-color: #e0e0e0;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 8px 24px rgba(65, 130, 110, 0.18);
}

/* ================================================
   Global Reset & Base
   ================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px;
}

body {
    font-family: 'Prompt', sans-serif;
    line-height: 1.7;
    color: var(--dark-grey-color);
    background-color: var(--white-color);
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

h1, h2, h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.text-left  { text-align: left; }
.center     { text-align: center; }

/* ================================================
   Header & Navbar
   ================================================ */
.header {
    background-color: var(--white-color);
    box-shadow: var(--shadow);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 80px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    font-size: 1.8rem;
}

.brand-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.nav-info {
    font-size: 0.9rem;
    color: #666;
    background: var(--light-grey-color);
    padding: 6px 14px;
    border-radius: 999px;
    font-weight: 600;
}

/* ================================================
   Layout & Sections
   ================================================ */
.vote-section {
    padding-top: 110px;
    padding-bottom: 80px;
    background-color: var(--light-grey-color);
    min-height: 100vh;
}

.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2rem;
    margin-bottom: 0.3rem;
}

.page-subtitle {
    color: #666;
    font-size: 1rem;
}

/* ================================================
   Filter Bar
   ================================================ */
.filter-bar {
    background-color: var(--white-color);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.filter-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 1rem;
    align-items: end;
}

.filter-actions {
    margin-top: 1rem;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.result-count {
    font-size: 0.9rem;
    color: #666;
    margin-left: 4px;
}

/* ================================================
   Cards & Schedule List
   ================================================ */
.repair-card {
    position: relative;
    background-color: #ffffff;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.schedule-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.ticket-card {
    border: 1px solid #e8eceb;
    border-radius: 12px;
    background: #fff;
    padding: 1.5rem;
    transition: box-shadow 0.2s ease-out, transform 0.2s;
    cursor: pointer;
}

.ticket-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.ticket-card.seats-full {
    opacity: 0.7;
}

/* Card Head */
.ticket-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--border-color);
    gap: 1rem;
}

.ticket-title {
    font-weight: 700;
    color: var(--dark-grey-color);
    font-size: 1.15rem;
    flex: 1;
}

.ticket-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* Card Body Grid */
.ticket-body {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.ticket-info-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ticket-info-label {
    font-size: 0.78rem;
    color: #888;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.ticket-info-value {
    font-size: 0.95rem;
    color: var(--dark-grey-color);
    font-weight: 500;
}

.ticket-info-value.highlight {
    color: var(--primary-color);
    font-weight: 700;
}

/* Route visual */
.route-display {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--dark-grey-color);
}

.route-arrow {
    color: var(--primary-color);
    font-size: 1rem;
}

/* Card Footer */
.ticket-footer {
    margin-top: 1rem;
    padding-top: 0.8rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.ticket-meta {
    color: #777;
    font-size: 0.85rem;
}

/* Seat Bar */
.seat-bar-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.seat-bar-label {
    font-size: 0.82rem;
    color: #666;
    white-space: nowrap;
}

.seat-bar {
    width: 100px;
    height: 7px;
    background: #e0e0e0;
    border-radius: 999px;
    overflow: hidden;
}

.seat-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.4s ease;
}

.seat-bar-fill.full   { background: #e74c3c; }
.seat-bar-fill.low    { background: #f39c12; }
.seat-bar-fill.ok     { background: var(--primary-color); }

/* ================================================
   Status Pills & Badges
   ================================================ */
.status-pill {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.80rem;
    font-weight: 700;
    white-space: nowrap;
}

.status-pill.new        { background: #eef3f2; color: #2d6a5a; }   /* ว่าง */
.status-pill.inprogress { background: #ffe9b3; color: #705b12; }   /* รอชำระเงิน */
.status-pill.done       { background: #bfe8c8; color: #12573f; }   /* ปกติ */
.status-pill.closed     { background: #ffcccc; color: #cc0000; }   /* เต็ม / ระงับ */

.badge-bus-type {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--primary-light);
    color: var(--primary-color);
    white-space: nowrap;
}

/* ================================================
   Skeleton Loading
   ================================================ */
.skeleton-card {
    height: 160px;
    border-radius: 12px;
    background: linear-gradient(90deg, #e8eceb 25%, #f4f7f6 50%, #e8eceb 75%);
    background-size: 400% 100%;
    animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
    0%   { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

/* ================================================
   Empty / Error State
   ================================================ */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--white-color);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: #777;
    font-size: 0.95rem;
}

/* ================================================
   Pagination
   ================================================ */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.page-btn {
    padding: 10px 20px;
    width: auto;
}

.page-numbers {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.page-num-btn {
    min-width: 40px;
    height: 40px;
    border: 1px solid var(--border-color);
    background: var(--white-color);
    border-radius: 8px;
    font-family: 'Prompt', sans-serif;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.page-num-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.page-num-btn.active {
    background: var(--primary-color);
    color: var(--white-color);
    border-color: var(--primary-color);
    font-weight: 700;
}

.page-num-btn.ellipsis {
    border: none;
    background: transparent;
    cursor: default;
    color: #888;
}

/* ================================================
   Forms & Inputs
   ================================================ */
.form-row {
    margin-bottom: 0;
    text-align: left;
}

.form-row label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: #555;
    font-size: 0.9rem;
}

.form-row input[type="text"],
.form-row select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: 'Prompt', sans-serif;
    font-size: 0.95rem;
    background: var(--white-color);
    transition: box-shadow 0.15s, border-color 0.15s;
    color: var(--dark-grey-color);
}

.form-row input[type="text"]:focus,
.form-row select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(65, 130, 110, 0.12);
}

.form-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: var(--white-color);
    cursor: pointer;
    transition: all 0.15s;
}
.form-row input[type="checkbox"]:checked {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

/* ================================================
   Buttons
   ================================================ */
.btn {
    display: inline-block;
    font-family: 'Prompt', sans-serif;
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background-color 0.25s ease, transform 0.1s ease;
    font-size: 0.95rem;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
    background-color: var(--primary-color);
    color: var(--white-color);
}

.btn-primary:hover { background-color: var(--primary-dark); }

.btn-secondary {
    background: #6c757d;
    color: #fff;
}

.btn-secondary:hover { background: #5a6268; }

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-danger:hover { background-color: #c0392b; }

.btn:disabled {
    background-color: #cccccc !important;
    color: #666666 !important;
    cursor: not-allowed;
    box-shadow: none;
}

/* ================================================
   Modals
   ================================================ */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, background 0.3s ease;
}

.modal.show {
    opacity: 1;
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.modal-card {
    width: min(560px, 94vw);
    background: #fff;
    border-radius: 14px;
    padding: 2rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: #999;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover { color: #333; }

.modal-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Modal Detail Sections */
.modal-section {
    margin-bottom: 1.2rem;
}

.modal-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.6rem;
}

.modal-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
}

.modal-detail-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.modal-detail-label {
    font-size: 0.8rem;
    color: #888;
    font-weight: 600;
}

.modal-detail-value {
    font-size: 0.95rem;
    color: var(--dark-grey-color);
    font-weight: 500;
}

.modal-route-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0.8rem;
    background: var(--light-grey-color);
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 1rem;
}

.modal-route-arrow {
    color: var(--primary-color);
    font-size: 1.4rem;
}

/* ================================================
   Utilities
   ================================================ */
.hidden { display: none !important; }

.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }

.status-message {
    font-size: 0.95rem;
    margin-top: 6px;
    color: #666;
}

.status-message.error {
    color: #e74c3c;
    font-weight: 600;
}

.text-small {
    font-size: 0.92rem;
    color: #666;
}

/* ================================================
   Icons & Labels
   ================================================ */
.icon {
        width: 1.1em;
        height: 1.1em;
        display: inline-block;
        vertical-align: -0.18em;
        flex-shrink: 0;
    }

    .icon-label {
        display: inline-flex;
        align-items: center;
        gap: 0.4rem;
    }

    .brand-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        color: #2563eb;
    }

    .empty-icon {
        display: flex;
        justify-content: center;
        align-items: center;
        margin-bottom: 12px;
    }

    .empty-icon .icon {
        width: 56px;
        height: 56px;
    }

    .icon-muted {
        color: #9ca3af;
    }

    .icon-warning {
        color: #f59e0b;
    }

    .inline-icon-text {
        display: inline-flex;
        align-items: center;
        gap: 0.35rem;
    }

/* ================================================
   Responsive
   ================================================ */
@media (max-width: 768px) {
    .filter-grid {
        grid-template-columns: 1fr 1fr;
    }

    .filter-grid .form-row:first-child {
        grid-column: 1 / -1;
    }

    .ticket-body {
        grid-template-columns: 1fr 1fr;
    }

    .ticket-body .ticket-info-group:last-child {
        grid-column: 1 / -1;
    }

    .modal-detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .filter-grid {
        grid-template-columns: 1fr;
    }

    .ticket-body {
        grid-template-columns: 1fr;
    }

    .ticket-head {
        flex-direction: column;
    }

    .ticket-badges {
        justify-content: flex-start;
    }

    .brand-name {
        font-size: 1rem;
    }

    .page-header h1 {
        font-size: 1.5rem;
    }
}