/**
 * KQXS Vietnam Pro - Frontend Styles
 * Mobile-first responsive design
 */

/* ========== Reset and Base Styles ========== */
.kqxs-container,
.kqxs-result-wrapper,
.kqxs-multi-results,
.kqxs-lookup-container,
.kqxs-loto-stats {
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    box-sizing: border-box;
}

.kqxs-container * {
    box-sizing: border-box;
}

/* ========== Loading State ========== */
.kqxs-loading {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 16px;
    background: #f9f9f9;
    border-radius: 8px;
}

.kqxs-loading::before {
    content: "";
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #e74c3c;
    border-radius: 50%;
    animation: kqxs-spin 1s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
}

@keyframes kqxs-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========== Error/No Result State ========== */
.kqxs-error,
.kqxs-no-result {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    color: #856404;
    text-align: center;
    font-size: 15px;
}

.kqxs-error {
    background: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

/* ========== Result Wrapper ========== */
.kqxs-result-wrapper,
.kqxs-multi-results {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin: 20px 0;
    overflow: hidden;
}

/* ========== Header ========== */
.kqxs-result-header,
.kqxs-multi-header,
.kqxs-loto-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
}

.kqxs-region-mb .kqxs-result-header,
.kqxs-region-mb.kqxs-multi-results .kqxs-multi-header {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.kqxs-region-mt .kqxs-result-header,
.kqxs-region-mt.kqxs-multi-results .kqxs-multi-header {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.kqxs-region-mn .kqxs-result-header,
.kqxs-region-mn.kqxs-multi-results .kqxs-multi-header {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.kqxs-title {
    margin: 0 0 8px 0;
    font-size: 20px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kqxs-date {
    font-size: 14px;
    opacity: 0.95;
    font-weight: 500;
}

/* ========== Old Result Notice ========== */
.kqxs-old-result-notice {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 12px 16px;
    margin-top: 12px;
    font-size: 14px;
    line-height: 1.6;
    backdrop-filter: blur(10px);
    text-align: center;
}

.kqxs-notice-icon {
    font-size: 18px;
    margin-right: 8px;
    display: inline-block;
}

.kqxs-old-result-notice small {
    opacity: 0.9;
    font-size: 12px;
    display: block;
    margin-top: 4px;
}

/* ========== Result Table ========== */
.kqxs-result-table-container {
    padding: 15px;
    overflow-x: auto;
}

.kqxs-result-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.kqxs-result-table tr {
    border-bottom: 1px solid #e9ecef;
}

.kqxs-result-table tr:last-child {
    border-bottom: none;
}

.kqxs-label {
    font-weight: 700;
    color: #495057;
    padding: 12px 15px;
    width: 100px;
    background: #f8f9fa;
    text-align: center;
    font-size: 14px;
    border-right: 2px solid #dee2e6;
}

.kqxs-numbers {
    padding: 12px 15px;
    text-align: center;
}

/* Prize Numbers */
.kqxs-number {
    display: inline-block;
    margin: 4px;
    position: relative;
}

.kqxs-num-full {
    display: inline-block;
    font-size: 18px;
    font-weight: 700;
    color: #212529;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    min-width: 80px;
    letter-spacing: 2px;
}

.kqxs-special-number .kqxs-num-full {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    font-size: 22px;
    padding: 12px 16px;
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.4);
}

.kqxs-num-last-two {
    display: block;
    font-size: 12px;
    color: #e74c3c;
    font-weight: 700;
    margin-top: 4px;
}

.kqxs-special-number .kqxs-num-last-two {
    color: #fff;
    font-size: 14px;
}

/* ========== Multi Province Table (Layout mẫu) ========== */
.kqxs-multi-table-container {
    padding: 15px;
    overflow-x: auto;
}

.kqxs-multi-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border: 1px solid #ddd;
}

.kqxs-multi-table thead th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 8px;
    font-weight: 700;
    text-align: center;
    font-size: 15px;
    border: 1px solid rgba(255,255,255,0.2);
}

.kqxs-region-mb .kqxs-multi-table thead th {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.kqxs-region-mt .kqxs-multi-table thead th {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.kqxs-region-mn .kqxs-multi-table thead th {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.kqxs-multi-table .kqxs-prize-col {
    width: 80px;
}

.kqxs-multi-table tbody tr {
    border-bottom: 1px solid #e9ecef;
}

.kqxs-multi-table tbody tr:last-child {
    border-bottom: none;
}

.kqxs-multi-table .kqxs-label {
    background: #f8f9fa;
    font-weight: 700;
    color: #495057;
    text-align: center;
    padding: 10px 8px;
    font-size: 13px;
    border-right: 2px solid #dee2e6;
    text-transform: capitalize;
}

.kqxs-multi-table .kqxs-numbers-cell {
    padding: 8px 6px;
    text-align: center;
    vertical-align: middle;
}

.kqxs-multi-table .kqxs-num {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: #212529;
    padding: 4px 0;
    letter-spacing: 1px;
    text-align: center;
}

.kqxs-multi-table .kqxs-num-special {
    display: block;
    font-size: 20px;
    font-weight: 900;
    color: #e74c3c;
    padding: 6px 0;
    letter-spacing: 2px;
    text-align: center;
}

/* Giải Tám màu đỏ */
.kqxs-multi-table tbody tr:first-child .kqxs-num,
.kqxs-multi-table tbody tr:nth-child(2) .kqxs-num {
    color: #e74c3c;
    font-weight: 900;
}

/* Giải Đặc Biệt */
.kqxs-multi-table .kqxs-special-row {
    background: #fff5f5;
}

.kqxs-multi-table .kqxs-special-row .kqxs-label {
    color: #e74c3c;
    font-weight: 900;
}

.kqxs-multi-table .kqxs-special-cell {
    background: linear-gradient(135deg, rgba(231, 76, 60, 0.05) 0%, rgba(231, 76, 60, 0.1) 100%);
}

.kqxs-empty {
    color: #999;
    font-size: 14px;
    text-align: center;
}

/* ========== Loto Controls ========== */
.kqxs-loto-controls {
    display: flex;
    gap: 10px;
    padding: 15px;
    background: #f8f9fa;
    border-top: 2px solid #dee2e6;
    justify-content: center;
    flex-wrap: wrap;
}

.kqxs-view-btn {
    padding: 10px 24px;
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 700;
    color: #495057;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kqxs-view-btn:hover {
    border-color: #667eea;
    color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.2);
}

.kqxs-view-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* View modes for numbers */
.kqxs-result-table .kqxs-num-full {
    display: inline-block;
}

.kqxs-result-table .kqxs-num-2digit,
.kqxs-result-table .kqxs-num-3digit {
    display: none;
}

/* When view mode = 2so */
.kqxs-result-wrapper.view-2so .kqxs-num-full {
    display: none;
}

.kqxs-result-wrapper.view-2so .kqxs-num-2digit {
    display: inline-block;
    font-size: 18px;
    font-weight: 700;
    color: #e74c3c;
}

/* When view mode = 3so */
.kqxs-result-wrapper.view-3so .kqxs-num-full {
    display: none;
}

.kqxs-result-wrapper.view-3so .kqxs-num-3digit {
    display: inline-block;
    font-size: 18px;
    font-weight: 700;
    color: #3498db;
}

/* Multi table view modes */
.kqxs-multi-results .kqxs-num-full {
    display: block;
}

.kqxs-multi-results .kqxs-num-2digit,
.kqxs-multi-results .kqxs-num-3digit {
    display: none;
}

.kqxs-multi-results.view-2so .kqxs-num-full {
    display: none;
}

.kqxs-multi-results.view-2so .kqxs-num-2digit {
    display: block;
    color: #e74c3c;
}

.kqxs-multi-results.view-3so .kqxs-num-full {
    display: none;
}

.kqxs-multi-results.view-3so .kqxs-num-3digit {
    display: block;
    color: #3498db;
}

/* ========== Loto Display Inline ========== */
.kqxs-loto-display,
.kqxs-loto-display-multi {
    padding: 15px;
    background: white;
}

.kqxs-loto-2so {
    max-width: 100%;
}

.kqxs-loto-table-inline {
    width: 100%;
    border-collapse: collapse;
}

.kqxs-loto-table-inline tr {
    border-bottom: 1px solid #e9ecef;
}

.kqxs-loto-table-inline tr:last-child {
    border-bottom: none;
}

.kqxs-loto-table-inline .kqxs-loto-head {
    width: 60px;
    background: #fff5f5;
    color: #e74c3c;
    font-weight: 700;
    font-size: 18px;
    text-align: center;
    padding: 10px;
    border-right: 2px solid #dee2e6;
}

.kqxs-loto-table-inline .kqxs-loto-nums {
    padding: 8px 12px;
    text-align: left;
}

.kqxs-loto-num {
    display: inline-block;
    background: #f8f9fa;
    color: #212529;
    font-weight: 700;
    font-size: 16px;
    padding: 6px 10px;
    margin: 3px;
    border-radius: 4px;
    min-width: 40px;
    text-align: center;
    letter-spacing: 1px;
}

.kqxs-loto-empty {
    color: #999;
    font-size: 14px;
}

/* Multi Loto Grid */
.kqxs-multi-loto-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.kqxs-province-loto h4 {
    margin: 0 0 10px 0;
    padding: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
    border-radius: 6px 6px 0 0;
    font-size: 15px;
}

/* ========== Loto Statistics ========== */
.kqxs-loto-stats {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin: 20px 0;
    overflow: hidden;
}

.kqxs-loto-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
}

.kqxs-loto-header h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
}

.kqxs-loto-table-container {
    padding: 15px;
    overflow-x: auto;
}

.kqxs-loto-table {
    width: 100%;
    border-collapse: collapse;
}

.kqxs-loto-table thead th {
    background: #f8f9fa;
    padding: 12px;
    font-weight: 700;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
    text-align: center;
    font-size: 14px;
}

.kqxs-loto-table tbody td {
    padding: 12px;
    border-bottom: 1px solid #e9ecef;
    text-align: center;
}

.kqxs-loto-head {
    font-weight: 700;
    color: #e74c3c;
    font-size: 18px;
    background: #fff5f5;
    width: 80px;
}

.kqxs-loto-numbers {
    font-weight: 600;
    color: #212529;
    letter-spacing: 1px;
    font-size: 15px;
}

/* ========== Lookup Form ========== */
.kqxs-lookup-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin: 20px 0;
    overflow: hidden;
}

.kqxs-lookup-form {
    padding: 25px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.kqxs-lookup-form h3 {
    margin: 0 0 20px 0;
    text-align: center;
    font-size: 20px;
}

.kqxs-form-row {
    margin-bottom: 15px;
}

.kqxs-form-row label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
}

.kqxs-select,
.kqxs-input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    font-size: 15px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    transition: all 0.3s ease;
}

.kqxs-select:focus,
.kqxs-input:focus {
    outline: none;
    border-color: white;
    background: white;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2);
}

.kqxs-button {
    width: 100%;
    padding: 14px 20px;
    background: white;
    color: #667eea;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.kqxs-button:hover {
    background: #f8f9fa;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.kqxs-lookup-result {
    padding: 20px;
}

/* ========== Mobile Responsive ========== */
@media (max-width: 768px) {
    .kqxs-container {
        padding: 10px;
    }
    
    .kqxs-result-wrapper,
    .kqxs-multi-results,
    .kqxs-lookup-container,
    .kqxs-loto-stats {
        border-radius: 8px;
        margin: 15px 0;
    }
    
    .kqxs-title {
        font-size: 16px;
    }
    
    .kqxs-multi-table-container {
        padding: 10px 5px;
    }
    
    .kqxs-multi-table thead th {
        font-size: 13px;
        padding: 10px 4px;
    }
    
    .kqxs-multi-table .kqxs-prize-col {
        width: 60px;
    }
    
    .kqxs-multi-table .kqxs-label {
        font-size: 12px;
        padding: 8px 4px;
    }
    
    .kqxs-multi-table .kqxs-num {
        font-size: 14px;
        padding: 3px 0;
    }
    
    .kqxs-multi-table .kqxs-num-special {
        font-size: 18px;
        padding: 4px 0;
    }
    
    .kqxs-loto-controls {
        padding: 10px;
        gap: 8px;
    }
    
    .kqxs-view-btn {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .kqxs-loto-table-inline .kqxs-loto-head {
        width: 50px;
        font-size: 16px;
        padding: 8px;
    }
    
    .kqxs-loto-num {
        font-size: 14px;
        padding: 5px 8px;
        min-width: 35px;
        margin: 2px;
    }
    
    .kqxs-multi-loto-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .kqxs-result-table-container,
    .kqxs-loto-table-container {
        padding: 10px;
    }
    
    .kqxs-label {
        width: 80px;
        padding: 10px 8px;
        font-size: 13px;
    }
    
    .kqxs-numbers {
        padding: 10px 8px;
    }
    
    .kqxs-num-full {
        font-size: 16px;
        padding: 6px 10px;
        min-width: 70px;
        letter-spacing: 1px;
    }
    
    .kqxs-special-number .kqxs-num-full {
        font-size: 20px;
        padding: 10px 14px;
    }
    
    .kqxs-lookup-form {
        padding: 20px 15px;
    }
    
    .kqxs-loto-head {
        width: 60px;
        font-size: 16px;
    }
    
    .kqxs-loto-numbers {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .kqxs-title {
        font-size: 14px;
    }
    
    .kqxs-date {
        font-size: 12px;
    }
    
    .kqxs-multi-table thead th {
        font-size: 11px;
        padding: 8px 2px;
    }
    
    .kqxs-multi-table .kqxs-prize-col {
        width: 50px;
    }
    
    .kqxs-multi-table .kqxs-label {
        font-size: 11px;
        padding: 6px 2px;
    }
    
    .kqxs-multi-table .kqxs-num {
        font-size: 13px;
    }
    
    .kqxs-multi-table .kqxs-num-special {
        font-size: 16px;
    }
    
    .kqxs-view-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .kqxs-loto-num {
        font-size: 13px;
        padding: 4px 6px;
        min-width: 32px;
    }
    
    .kqxs-num-full {
        font-size: 15px;
        padding: 5px 8px;
        min-width: 60px;
        margin: 3px;
    }
    
    .kqxs-special-number .kqxs-num-full {
        font-size: 18px;
        padding: 8px 12px;
    }
    
    .kqxs-label {
        width: 70px;
        font-size: 12px;
        padding: 8px 5px;
    }
}

/* ========== Utility Classes ========== */
.kqxs-text-center {
    text-align: center;
}

.kqxs-text-red {
    color: #e74c3c;
}

.kqxs-text-blue {
    color: #3498db;
}

.kqxs-hide {
    display: none;
}

.kqxs-show {
    display: block;
}

/* ========== Print Styles ========== */
@media print {
    .kqxs-lookup-form,
    .kqxs-button {
        display: none;
    }
    
    .kqxs-result-wrapper,
    .kqxs-multi-results {
        box-shadow: none;
        page-break-inside: avoid;
    }
}
