/* styles.css - Updated */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #60bbe9 100%);
    min-height: 100vh;
    color: #333;
} */

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

header {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 25px;
    font-size: 2.5rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.separator {
    font-size: 14px;
    font-weight: 600;
    color: #7f8c8d;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0 20px;
    position: relative;
}

.separator::before,
.separator::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 50px;
    height: 1px;
    background: #bdc3c7;
}

.separator::before {
    left: -70px;
}

.separator::after {
    right: -70px;
}

#excelFile,
#sheetsUrl {
    padding: 12px 20px;
    border: 2px solid #ddd;
    border-radius: 25px;
    background: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 300px;
}

#sheetIndex {
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 25px;
    background: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 100px;
}

#sheetsUrl {
    cursor: text;
}

#excelFile:hover,
#sheetsUrl:hover,
#sheetsUrl:focus,
#sheetIndex:hover,
#sheetIndex:focus {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
    outline: none;
}

button {
    padding: 12px 25px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#loadChart {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

#loadChart:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

#loadChart:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#clearChart {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
}

#clearChart:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(238, 90, 111, 0.4);
}

.status {
    text-align: center;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-weight: 500;
    animation: fadeIn 0.5s ease;
}

.status.success {
    background: linear-gradient(135deg, #56ab2f 0%, #a8e6cf 100%);
    color: white;
}

.status.error {
    background: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
    color: white;
}

.status.info {
    background: linear-gradient(135deg, #3498db 0%, #74b9ff 100%);
    color: white;
}

.status.hidden {
    display: none;
}

main {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-height: 400px;
}

.chart-title {
    text-align: center;
    font-size: 1.8rem;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 30px;
    line-height: 1.4;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.seating-chart {
    display: grid;
    gap: 2px;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 12px;
    border: 2px solid #e9ecef;
    max-width: 100%;
    overflow: auto;
    padding: 15px;
    /* Kích thước grid tối ưu - sẽ được điều chỉnh dynamically */
    grid-template-columns: repeat(25, 47px);
    grid-template-rows: repeat(37, 47px);
}

.seating-chart.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    flex-direction: column;
    color: #6c757d;
}

.seating-chart.empty::before {
    content: "📊";
    font-size: 4rem;
    margin-bottom: 15px;
}

.seating-chart.empty::after {
    content: "Chưa có dữ liệu. Vui lòng tải file Excel hoặc nhập link Google Sheets để xem sơ đồ hội trường.";
    font-size: 1.2rem;
    text-align: center;
    max-width: 400px;
}

.seat {
    width: 45px;
    height: 45px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    border: 2px solid transparent;
    text-align: center;
    word-wrap: break-word;
    line-height: 1.2;
}

.seat::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s ease;
}

.seat:hover::before {
    left: 100%;
}

.seat.seat-number {
  background: linear-gradient(135deg, #74ce8c 0%, #2cc84c 100%);
  color: #2d3436;
  cursor: default;
}

/* Ghế số dài (đã có) – fit theo content */
.seat.seat-number.seat-flex {
  width: auto;
  height: auto;
  padding: 6px 10px;
  white-space: normal;
  overflow: visible;
}

/* Thành phần khác - cải thiện hiển thị tên */
.seat.facility {
    background: #9db1cf;
    color: #1e1b4b;
    cursor: default;
    font-weight: 700;
    font-size: 12px;
    white-space: normal;
    text-align: center;
    /* min-width: 45px; */
    padding: 4px 6px;
    line-height: 1.2;
    display: flex;
    align-items: center;
    justify-content: center;
    word-break: break-word;
    hyphens: auto;
}

/* Tên dài cần font size lớn hơn */
.seat.facility.long-text {
    font-size: 11px;
    line-height: 1.1;
    padding: 3px 5px;
}

/* Tên rất dài vẫn giữ font size đọc được */
.seat.facility.very-long-text {
    font-size: 10px;
    line-height: 1.0;
    padding: 2px 4px;
}

.seat.facility:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
}

.seat.facility:hover::before {
    left: -100%;
}

.seat:active {
    transform: scale(0.95);
}

.seat::before,
.seat:hover::before {
  content: none !important;
}

/* Ô facility có nhãn ghế (ví dụ: "V.M.Trinh (4A)") hiển thị như ghế xanh */
.seat.facility.facility-seat {
  background: linear-gradient(135deg, #74ce8c 0%, #2cc84c 100%);
  color: #2d3436;
  border: 2px solid transparent;
}

/* Khi đã điểm danh, vẫn bị xám như ghế thường */
.seat.facility.facility-seat.checked {
  background: #bebcbc !important;
  border-color: #9ca3af !important;
  color: #111827 !important;
}

/* Khi highlight, dùng hiệu ứng giống ghế */
.seat.facility.facility-seat.highlight {
  background: #ff0000 !important;
  border-color: #ff0000 !important;
  color: #fff !important;
  font-weight: bold;
  animation: pulseHighlight 1s infinite;
}


footer {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.legend {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    color: #2c3e50;
}

.legend .seat {
    width: 30px;
    height: 30px;
    font-size: 10px;
    cursor: default;
    pointer-events: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.seat {
    animation: slideIn 0.3s ease;
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
        max-width: 98%;
    }

    h1 {
        font-size: 2rem;
    }

    .controls {
        gap: 15px;
    }

    .input-group {
        flex-direction: column;
        gap: 10px;
    }

    #excelFile,
    #sheetsUrl {
        min-width: auto;
        width: 100%;
        max-width: 300px;
    }

    .separator::before,
    .separator::after {
        width: 30px;
    }

    .separator::before {
        left: -50px;
    }

    .separator::after {
        right: -50px;
    }

    .legend {
        gap: 15px;
    }

    .seating-chart {
        padding: 10px;
        gap: 1px;
        /* Điều chỉnh grid cho mobile */
        grid-template-columns: repeat(auto-fit, minmax(35px, 1fr));
        max-width: 100%;
        overflow-x: auto;
    }

    .seat {
        min-width: 35px;
        min-height: 35px;
        font-size: 10px;
    }

    .seat.facility {
        font-size: 8px;
    }

    .chart-title {
        font-size: 1.4rem;
    }
}

/* Responsive cho màn hình dọc tablet/mobile lớn (portrait) như 1080x1920 */
@media (max-width: 1200px) and (min-width: 769px) {
    .container {
        max-width: 100%;
        padding: 15px;
    }

    h1 {
        font-size: 2.2rem;
        margin-bottom: 20px;
    }

    header {
        padding: 25px;
        margin-bottom: 25px;
    }

    main {
        padding: 25px;
        margin-bottom: 25px;
    }

    .chart-title {
        font-size: 1.6rem;
        margin-bottom: 25px;
    }

    .seating-chart {
        padding: 12px;
        gap: 1.5px;
        /* Tối ưu cho màn hình dọc */
        justify-content: center;
        max-width: 100%;
        overflow: auto;
    }

    .seat {
        width: 40px;
        height: 40px;
        font-size: 10px;
    }

    .seat.facility {
        font-size: 11px;
        padding: 3px 5px;
    }

    .seat.facility.long-text {
        font-size: 10px;
    }

    .seat.facility.very-long-text {
        font-size: 9px;
    }

    .legend {
        gap: 25px;
        justify-content: center;
        flex-wrap: wrap;
    }

    .legend .seat {
        width: 25px;
        height: 25px;
        font-size: 9px;
    }

    footer {
        padding: 18px;
    }
}

/* Responsive cho màn hình rất lớn */
@media (min-width: 1201px) {
    .container {
        max-width: 1400px;
    }

    .seating-chart {
        justify-content: center;
    }
}

/* Ghế đã check-in (tô xám) */
.seat.checked {
    background: #bebcbc !important;
    /* xám */
    border: 2px solid #9ca3af !important;
    color: #111827 !important;
}

/* Ghế được highlight sau khi check-in */
.seat.highlight {
    background: #ff0000 !important;
    /* dùng background thay vì background-color để override gradient */
    border: 2px solid #ff0000 !important;
    color: #fff !important;
    font-weight: bold;
    animation: pulseHighlight 1s infinite;
}

@keyframes pulseHighlight {
    0% {
        box-shadow: 0 0 5px #ff0000;
    }

    50% {
        box-shadow: 0 0 15px #ff0000;
    }

    100% {
        box-shadow: 0 0 5px #ff0000;
    }
}

/* Toast nhỏ gọn */
.app-toast {
    position: fixed;
    left: 50%;
    bottom: 8%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 14px 22px;
    border-radius: 12px;
    font-size: 30px;
    /* cỡ chữ lớn như yêu cầu */
    line-height: 1.2;
    z-index: 9999;
    opacity: 0;
    transition: opacity .2s ease, transform .2s ease;
    pointer-events: none;
    text-align: center;
    max-width: 90vw;
}

.app-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(-6px);
}