/* ==================== RESET & VARIABLES ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --secondary: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --dark: #1f2937;
    --light: #f3f4f6;
    --white: #ffffff;
    --border: #e5e7eb;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--dark);
    line-height: 1.6;
}

/* ==================== LAYOUT ==================== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 2px;
    padding: 10px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.logo {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-name {
    font-weight: 600;
    color: var(--dark);
}

.user-role {
    background: var(--primary);
    color: var(--white);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 14px;
}

.nav {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 20px;
    padding: 7px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    overflow-x: visible;
}

.nav a {
    padding: 10px 20px;
    text-decoration: none;
    color: var(--dark);
    border-radius: 8px;
    transition: all 0.3s;
    white-space: nowrap;
    font-weight: 500;
}

.nav a:hover {
    background: var(--light);
}

.nav a.active {
    background: var(--primary);
    color: var(--white);
}

.main-content {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 6px;
    min-height: 500px;
}

.footer {
    color: #e0e9e6;
    font-weight: bold;
    text-align: center;
    padding: 15px;
}

/* ==================== GRID BÀN - 4 CỘT DESKTOP ==================== */
.grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin: 15px 0;
}

/* ==================== BÀN CHƠI - COMPACT ==================== */
.table-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--white);
    border-radius: 10px;
    padding: 15px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.table-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.table-card.in-use {
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
}

.table-card.available {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.table-name {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 8px;
}

.table-price {
    display: none !important;
}

.table-status {
    font-size: 13px;
    font-weight: 600;
    padding: 5px 10px;
    margin: 8px 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    display: inline-block;
}

.table-time {
    font-size: 18px;
    font-weight: 900;
    margin: 8px 0;
    font-family: 'Courier New', monospace;
}

.table-action-btn {
    width: 100%;
    padding: 12px 8px;
    font-size: 14px;
    font-weight: 800;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 8px;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.06);
}

.btn-success.table-action-btn {
    animation: pulse-green 2s infinite;
}

.btn-warning.table-action-btn {
    animation: pulse-orange 2s infinite;
}

.btn-secondary.table-action-btn {
    background: linear-gradient(135deg, #5a4204, #c97720 85%);
    color: #fff;
}

.btn-secondary.table-action-btn:hover {
    background: linear-gradient(135deg,#f59e42,#ffbb00 85%);
    transform: translateY(-2px) scale(1.04);
}

/* ==================== FORMS ==================== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--dark);
}

.form-input,
.form-select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.3s;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ==================== BUTTONS ==================== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

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

.btn-success:hover {
    background: #059669;
    transform: translateY(-2px);
}

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

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-2px);
}

.btn-warning {
    background: #4c9d0a;
    color: var(--white);
}

.btn-warning:hover {
    background: #d97706;
    transform: translateY(-2px);
}

.btn-small {
    padding: 8px 16px;
    font-size: 14px;
}

.btn-block {
    width: 100%;
}

.btn-logout {
    background: var(--danger);
    color: var(--white);
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
}

/* ==================== TABLES ==================== */
.table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    background: var(--white);
    border-radius: 8px;
    overflow: hidden;
    font-size: 15px;
}

.table th,
.table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    background: var(--light);
    font-weight: 700;
    color: var(--dark);
}

.table tbody tr:hover {
    background: var(--light);
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ==================== CARDS ==================== */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
}

/* ==================== STATS ==================== */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.stat-card {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
    padding: 25px;
    border-radius: 12px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 10px;
}

.stat-label {
    font-size: 14px;
    opacity: 0.9;
}

/* ==================== ALERTS ==================== */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 15px;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

/* ==================== MODAL ==================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
    overflow-y: auto;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: 18px;
    padding: 25px 20px;
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 36px rgba(0,0,0,.14);
    color: var(--dark);
}

.modal-content * {
    color: var(--dark);
}

.modal-content .text-muted {
    color: #6b7280 !important;
}

.modal-header {
	display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #4f35df;
    margin-bottom: 8px;
    padding-bottom: 5px;
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--dark);
}

.modal-close {
    background: var(--light);
    color: var(--dark);
    font-size: 24px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #fee2e2;
    color: #dc2626;
}

.modal-body {
    padding: 10px 0;
}

/* ==================== INVOICE ==================== */
.invoice {
    background: var(--white);
    padding: 2px;
    border-radius: 8px;
    border: 2px solid var(--border);
}

.invoice-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border);
}

.invoice-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 10px;
}

.invoice-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 18px;
}

.invoice-item {
    display: flex;
    justify-content: space-between;
    padding: 4px;
    background: #d7dae1;
    border-radius: 6px;
    font-size: 15px;
}

.invoice-item strong,
.invoice-item span {
    color: var(--dark);
    font-weight: 600;
}

.invoice-total {
    text-align: right;
    font-size: 22px;
    font-weight: 900;
    color: var(--primary);
    margin-top: 15px;
    padding: 15px;
    border-top: 2px solid var(--border);
    background: var(--light);
    border-radius: 8px;
}

.invoice-footer {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 2px solid var(--border);
    font-size: 13px;
}

/* ==================== SERVICE LIST ==================== */
.service-row {
    display: grid;
    grid-template-columns: 2fr 1.2fr 1fr;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}

.service-row:hover {
    background: var(--light);
}

.service-header {
    background: var(--light);
    font-weight: 700;
    border-bottom: 2px solid var(--primary);
    font-size: 15px;
}

.service-name-col {
    text-align: left;
    font-weight: 600;
    font-size: 15px;
}

.service-price-col {
    text-align: center;
    color: var(--primary);
    font-weight: 700;
    font-size: 15px;
}

.service-qty-col {
    text-align: right;
    font-weight: 700;
    color: var(--secondary);
    font-size: 16px;
}

.service-table-row {
    cursor: pointer;
}

.service-table-row.selected-row {
    background: #e0f2fe !important;
    border-left: 4px solid var(--primary);
}

.quantity-input {
    width: 80px !important;
    text-align: center;
    padding: 8px;
    font-size: 14px;
    border: 2px solid var(--border);
    border-radius: 6px;
    transition: all 0.3s;
}

.quantity-input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ==================== CHANGE TABLE MODAL ==================== */
.available-table {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #e0fbff;
    padding: 12px 16px;
    margin-bottom: 8px;
    border-radius: 8px;
    font-size: 16px;
}

.available-table button {
    background: #16a34a;
    color: #fff;
    border-radius: 6px;
    padding: 7px 16px;
    font-weight: 700;
    border: none;
    cursor: pointer;
}

.available-table button:hover {
    background: #059669;
}

/* ==================== LOGIN PAGE ==================== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    background: var(--white);
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    width: 100%;
}

.login-title {
    text-align: center;
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 30px;
}

/* ==================== UTILITIES ==================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: #6b7280; font-size: 13px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-10 { gap: 10px; }
.page-header { margin-bottom: 20px; }
.page-header h2 { font-size: 28px; font-weight: 700; }

.badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
}

.badge-success { background: #10b981; color: white; }
.badge-primary { background: #3b82f6; color: white; }
.badge-danger { background: #ef4444; color: white; }

/* ==================== ANIMATIONS ==================== */
@keyframes pulse-green {
    0%, 100% { box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4); }
    50% { box-shadow: 0 6px 25px rgba(16, 185, 129, 0.7); }
}

@keyframes pulse-orange {
    0%, 100% { box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4); }
    50% { box-shadow: 0 6px 25px rgba(245, 158, 11, 0.7); }
}

/* ==================== RESPONSIVE ==================== */

/* Tablet ngang (1024-1199px) */
@media (max-width: 1199px) and (min-width: 1024px) {
    .grid { grid-template-columns: repeat(3, 1fr); }
}

/* Tablet dọc (768-1023px) */
@media (max-width: 1023px) and (min-width: 768px) {
    .grid { grid-template-columns: repeat(2, 1fr); }
    .stats { grid-template-columns: repeat(2, 1fr); }
}

/* Mobile (< 768px) - MENU 4 CỘT NGANG (2 DÒNG) */
@media (max-width: 767px) {
    .container { padding: 10px; }
    
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    /* MENU 4 CỘT NGANG - 2 DÒNG */
    .nav {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
        padding: 12px;
        overflow: visible;
        height: auto;
        min-height: auto;
    }
    
    .nav a {
        padding: 12px 8px;
        font-size: 13px;
        text-align: center;
        white-space: normal;
        min-height: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
        line-height: 1.2;
    }
    
    .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    
    .table-card {
        padding: 12px 8px;
        min-height: 135px;
    }
    
    .table-name { font-size: 18px; }
    .table-time { font-size: 17px; }
    .table-action-btn { font-size: 13px; padding: 10px 6px; }
    
    .modal-content {
        max-width: 95%;
        padding: 20px 15px;
    }
    
    .invoice-info { grid-template-columns: 1fr; }
    
    .service-row {
        grid-template-columns: 2fr 1fr 0.8fr;
        gap: 8px;
        padding: 10px 8px;
    }
    
    .stats { grid-template-columns: 1fr; }
}

/* Mobile nhỏ (< 480px) */
@media (max-width: 480px) {
    .nav {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        padding: 10px;
    }
    
    .nav a {
        padding: 10px 6px;
        font-size: 13px;
    }
    
    .grid { grid-template-columns: 1fr; }
    
    .table-card {
        padding: 15px 12px;
        min-height: 130px;
    }
    
    .table-name { font-size: 19px; }
    .table-time { font-size: 18px; }
    
    .modal-content { max-width: 98%; padding: 15px; }
    .modal-title { font-size: 17px; }
    
    .service-row {
        grid-template-columns: 2fr 1fr 0.7fr;
        font-size: 14px;
    }
}

/* Landscape mobile - MENU 4 CỘT NGANG */
@media (max-width: 900px) and (orientation: landscape) {
    .nav {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }
    
    .nav a {
        font-size: 13px;
        padding: 10px 6px;
    }
    
    .grid { grid-template-columns: repeat(3, 1fr); }
    .table-card { min-height: 120px; padding: 10px; }
    .table-name { font-size: 16px; }
    .table-time { font-size: 15px; }
}

/* Touch devices */
@media (hover: none) and (pointer: coarse) {
    .btn, .table-action-btn, .modal-close {
        min-height: 44px;
        min-width: 44px;
    }
    
    .nav a {
        min-height: 44px;
    }
    
    .form-input, .form-select {
        min-height: 48px;
        font-size: 16px;
    }
}

/* ==================== PRINT ==================== */
@media print {
    .header, .nav, .btn, .modal-close { display: none !important; }
    .modal { display: block !important; position: static !important; background: white !important; }
    .invoice { page-break-inside: avoid; }
}