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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    padding: 15px;
}

header {
    text-align: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
}

header h1 {
    color: #667eea;
    margin-bottom: 5px;
    font-size: 1.5em;
}

.subtitle {
    color: #666;
    font-size: 0.9em;
}

.admin-controls {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    gap: 20px;
}

.admin-selector label {
    margin-right: 10px;
    font-weight: bold;
}

.admin-selector select {
    padding: 8px 15px;
    border: 2px solid #667eea;
    border-radius: 5px;
    font-size: 1em;
}

.main-content {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 10px;
    max-height: calc(100vh - 180px);
    overflow: hidden;
}

.left-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    max-height: 100%;
}

.right-column {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: 100%;
}

.manual-input-section {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
}

.manual-input-section h2 {
    margin-bottom: 8px;
    color: #333;
    font-size: 1em;
}

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

.input-group textarea {
    flex: 1;
    padding: 6px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 0.85em;
    resize: none;
    min-height: 50px;
    max-height: 50px;
}

.selected-numbers-section {
    background: #e8f4f8;
    padding: 10px;
    border-radius: 8px;
}

.selected-numbers-section h2 {
    margin-bottom: 8px;
    color: #333;
    font-size: 1em;
}

.selected-numbers-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
    min-height: 40px;
}

.number-badge {
    display: inline-block;
    padding: 6px 12px;
    background: #667eea;
    color: white;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.number-badge:hover {
    background: #5568d3;
    transform: scale(1.05);
}

.numbers-grid-section {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.numbers-grid-section h2 {
    margin-bottom: 6px;
    color: #333;
    font-size: 0.95em;
    flex-shrink: 0;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 6px;
    flex-shrink: 0;
    padding: 5px;
    background: white;
    border-radius: 5px;
    font-size: 0.8em;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-box {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    border: 1px solid #ddd;
}

.legend-box.available {
    background: #d4edda;
}

.legend-box.reserved {
    background: #fff3cd;
}

.legend-box.sold {
    background: #f8d7da;
}

.legend-box.selected {
    background: #667eea;
}

.numbers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
    gap: 3px;
    flex: 1;
    overflow-y: auto;
    padding: 6px;
    background: white;
    border-radius: 5px;
    min-height: 0;
}

.number-cell {
    padding: 6px 2px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.85em;
    font-weight: bold;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.number-cell.available {
    background: #d4edda;
    color: #155724;
}

.number-cell.available:hover {
    background: #c3e6cb;
    transform: scale(1.05);
}

.number-cell.reserved {
    background: #fff3cd;
    color: #856404;
    cursor: not-allowed;
}

.number-cell.sold {
    background: #f8d7da;
    color: #721c24;
    cursor: not-allowed;
}

.number-cell.selected {
    background: #667eea;
    color: white;
    border-color: #5568d3;
}

.user-info-form {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
    border: 2px solid #667eea;
}

.user-info-form h2 {
    margin-bottom: 10px;
    color: #333;
    font-size: 1em;
}

.form-group {
    margin-bottom: 8px;
}

.form-group label {
    display: block;
    margin-bottom: 3px;
    font-weight: bold;
    color: #333;
    font-size: 0.85em;
}

.form-group input {
    width: 100%;
    padding: 6px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 0.85em;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.reservation-actions {
    text-align: center;
    padding: 5px;
}

.payment-notice {
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 8px;
    padding: 10px;
    margin-top: 10px;
    font-size: 0.8em;
    flex-shrink: 0;
}

.payment-notice p {
    margin: 5px 0;
    color: #856404;
}

.payment-notice strong {
    color: #856404;
}

.btn {
    padding: 6px 12px;
    border: none;
    border-radius: 5px;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

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

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

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

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

.btn-danger:hover {
    background: #c82333;
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-info:hover {
    background: #138496;
}

.btn-warning {
    background: #ffc107;
    color: #212529;
    border: none;
}

.btn-warning:hover {
    background: #e0a800;
    color: #212529;
}

.btn-small {
    padding: 4px 8px;
    font-size: 0.8em;
    min-width: auto;
}

.btn-large {
    padding: 15px 40px;
    font-size: 1.2em;
}

.alert {
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.hidden {
    display: none !important;
}

/* Đảm bảo modal bị ẩn khi có class hidden */
.modal.hidden {
    display: none !important;
}

/* Admin styles */
.admin-main-content {
    display: block;
    width: 100%;
}

.filters {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    width: 100%;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-group label {
    font-weight: bold;
    white-space: nowrap;
}

.filter-group select,
.filter-group input {
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
}

.filter-group-search {
    flex: 1;
    min-width: 300px;
}

.filter-group-search input {
    width: 100%;
    min-width: 300px;
}

.table-container {
    overflow-x: auto;
    min-width: 100%;
}

/* Giữ nguyên kích thước bảng khi đang loading */
.table-container.loading {
    min-width: 100%;
}

.table-container.loading table {
    width: 100%;
    table-layout: fixed;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 5px;
    overflow: hidden;
}

table thead {
    background: #667eea;
    color: white;
}

table th,
table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

table tbody tr:hover {
    background: #f8f9fa;
}

.reservations-list {
    width: 100%;
    display: block;
    margin-top: 0;
}

.reservations-list h2 {
    margin-bottom: 15px;
    color: #333;
}

.status-badge {
    padding: 5px 10px;
    border-radius: 3px;
    font-size: 0.9em;
    font-weight: bold;
}

.status-pending {
    background: #fff3cd;
    color: #856404;
}

.status-paid {
    background: #cce5ff;
    color: #004085;
}

.status-approved {
    background: #d4edda;
    color: #155724;
}

.status-rejected {
    background: #f8d7da;
    color: #721c24;
}

.status-expired {
    background: #e2e3e5;
    color: #383d41;
}

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

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 8px;
    max-width: 900px;
    width: 95%;
    max-height: 95vh;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.modal-header h2 {
    margin: 0;
    color: #667eea;
    font-size: 1.1em;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2em;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: all 0.3s;
}

.modal-close:hover {
    color: #333;
    background: #f0f0f0;
    border-radius: 50%;
}

.modal-body {
    padding: 10px 12px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.detail-info {
    margin-bottom: 8px;
    background: #f8f9fa;
    padding: 6px;
    border-radius: 5px;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 6px;
    background: white;
    border-radius: 3px;
    border-left: 2px solid #667eea;
    font-size: 0.85em;
}

.info-label {
    font-weight: bold;
    color: #333;
    min-width: 90px;
    font-size: 0.85em;
    margin-right: 8px;
}

.info-value {
    color: #666;
    font-size: 0.85em;
    text-align: right;
    flex: 1;
    word-break: break-word;
}

.detail-numbers {
    margin-bottom: 8px;
}

.detail-numbers h3 {
    font-size: 0.9em;
    margin-bottom: 4px;
    color: #333;
}

.numbers-list-editable {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
    padding: 4px;
    background: #f8f9fa;
    border-radius: 4px;
    min-height: 40px;
    max-height: 100px;
    overflow-y: auto;
    font-size: 0.85em;
}

.edit-numbers {
    margin-top: 6px;
}

.edit-numbers textarea {
    width: 100%;
    padding: 5px;
    border: 2px solid #ddd;
    border-radius: 4px;
    margin-bottom: 5px;
    min-height: 50px;
    font-size: 0.8em;
    resize: vertical;
}

.modal-actions {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.action-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.action-buttons .btn {
    flex: 1;
    min-width: 140px;
    padding: 8px 12px;
    font-size: 0.9em;
}

.action-warning {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 5px;
    padding: 8px;
    margin-top: 8px;
}

.warning-text {
    margin: 0;
    color: #856404;
    font-weight: bold;
    text-align: center;
    font-size: 0.85em;
}

/* Responsive - Mobile First Approach */
@media (max-width: 768px) {
    /* Body và Container */
    body {
        padding: 10px;
    }
    
    .container {
        padding: 10px;
        border-radius: 8px;
    }
    
    /* Header */
    header h1 {
        font-size: 1.2em;
    }
    
    header .subtitle {
        font-size: 0.8em;
    }
    
    /* Main Content - Chuyển từ 2 cột sang 1 cột */
    .main-content {
        grid-template-columns: 1fr;
        gap: 15px;
        max-height: none;
    }
    
    .left-column {
        order: 2;
        max-height: none;
    }
    
    .right-column {
        order: 1;
        max-height: none;
    }
    
    /* Numbers Grid - Điều chỉnh kích thước cell */
    .numbers-grid {
        grid-template-columns: repeat(auto-fill, minmax(45px, 1fr));
        gap: 4px;
        padding: 8px;
    }
    
    .number-cell {
        padding: 8px 4px;
        font-size: 0.8em;
        min-height: 36px;
    }
    
    /* Legend - Xếp dọc trên mobile */
    .legend {
        flex-direction: column;
        gap: 5px;
    }
    
    .legend-item {
        font-size: 0.75em;
    }
    
    /* Form và Input */
    .input-group {
        flex-direction: column;
    }
    
    .input-group textarea {
        min-height: 60px;
        max-height: 60px;
    }
    
    .input-group button {
        width: 100%;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }
    
    /* Selected Numbers */
    .selected-numbers-list {
        gap: 6px;
    }
    
    .number-badge {
        padding: 5px 10px;
        font-size: 0.85em;
    }
    
    /* Buttons */
    .btn-large {
        padding: 12px 20px;
        font-size: 1em;
        width: 100%;
    }
    
    /* Admin Controls */
    .admin-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .admin-selector {
        width: 100%;
    }
    
    .admin-selector label {
        display: block;
        margin-bottom: 5px;
    }
    
    .admin-selector select {
        width: 100%;
    }
    
    /* Admin Header Links */
    header > div {
        flex-direction: column;
        gap: 10px;
    }
    
    header > div a {
        display: block;
        margin: 5px 0 !important;
        text-align: center;
        padding: 8px;
        background: #f8f9fa;
        border-radius: 5px;
    }
    
    /* Admin Tools - Xếp dọc */
    .admin-tools > div {
        grid-template-columns: 1fr !important;
    }
    
    .admin-tools h3 {
        font-size: 1em;
    }
    
    .admin-tools h4 {
        font-size: 0.9em;
    }
    
    /* Filters */
    .filters {
        flex-direction: column;
        gap: 10px;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .filter-group-search {
        min-width: 100%;
    }
    
    .filter-group-search input {
        min-width: 100%;
    }
    
    /* Table - Scroll ngang trên mobile */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 600px;
        font-size: 0.85em;
    }
    
    table th,
    table td {
        padding: 8px 6px;
        white-space: nowrap;
    }
    
    /* Status Badge */
    .status-badge {
        padding: 3px 8px;
        font-size: 0.75em;
    }
    
    /* Modal */
    .modal-content {
        width: 95%;
        max-height: 90vh;
        margin: 10px;
    }
    
    .modal-header h2 {
        font-size: 1em;
    }
    
    .modal-body {
        padding: 10px;
    }
    
    /* Info Grid - 1 cột trên mobile */
    .info-grid {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    
    .info-row {
        flex-direction: column;
        align-items: flex-start;
        padding: 8px;
    }
    
    .info-label {
        margin-bottom: 4px;
        min-width: auto;
    }
    
    .info-value {
        text-align: left;
        width: 100%;
    }
    
    /* Action Buttons */
    .action-buttons {
        flex-direction: column;
    }
    
    .action-buttons .btn {
        width: 100%;
        min-width: auto;
    }
    
    /* Payment Notice */
    .payment-notice {
        font-size: 0.75em;
        padding: 8px;
    }
    
    /* User Info Form */
    .user-info-form {
        padding: 12px;
    }
    
    .user-info-form h2 {
        font-size: 0.95em;
    }
    
    /* Numbers List Editable */
    .numbers-list-editable {
        font-size: 0.8em;
        gap: 3px;
    }
    
    /* Edit Numbers */
    .edit-numbers textarea {
        font-size: 0.85em;
        min-height: 70px;
    }
}

/* Responsive cho màn hình nhỏ hơn (điện thoại nhỏ) */
@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    
    .container {
        padding: 8px;
    }
    
    header h1 {
        font-size: 1em;
    }
    
    .numbers-grid {
        grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
        gap: 3px;
    }
    
    .number-cell {
        padding: 6px 2px;
        font-size: 0.75em;
        min-height: 32px;
    }
    
    table {
        min-width: 500px;
        font-size: 0.8em;
    }
    
    table th,
    table td {
        padding: 6px 4px;
    }
    
    .modal-content {
        width: 98%;
        margin: 5px;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 0.85em;
    }
}

/* Responsive cho Payment Guide */
@media (max-width: 768px) {
    .payment-guide-container {
        padding: 10px;
    }
    
    .payment-guide-header h1 {
        font-size: 1.5em;
    }
    
    .payment-guide-content {
        padding: 15px;
    }
    
    .intro-section {
        padding: 15px;
    }
    
    .intro-section p {
        font-size: 0.95em;
    }
    
    .community-section {
        padding: 15px;
    }
    
    .community-section h3 {
        font-size: 1.2em;
    }
    
    .contact-item {
        padding: 10px;
    }
}

/* Responsive cho Login */
@media (max-width: 768px) {
    .login-container {
        max-width: 90%;
        margin: 50px auto;
        padding: 25px 20px;
    }
    
    .login-form h2 {
        font-size: 1.3em;
    }
}

/* Responsive cho Admin Logs và Management */
@media (max-width: 768px) {
    .admin-logs-container,
    .admin-management-container {
        padding: 10px;
    }
    
    .admin-logs-table-container,
    .admin-management-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .admin-logs-table,
    .admin-management-table {
        min-width: 700px;
        font-size: 0.85em;
    }
    
    .admin-logs-table th,
    .admin-logs-table td,
    .admin-management-table th,
    .admin-management-table td {
        padding: 8px 6px;
    }
}

/* Landscape orientation trên mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .main-content {
        grid-template-columns: 300px 1fr;
    }
    
    .left-column {
        order: 1;
    }
    
    .right-column {
        order: 2;
    }
    
    .numbers-grid {
        grid-template-columns: repeat(auto-fill, minmax(35px, 1fr));
    }
}

