:root {
    --primary: #F97316;
    --primary-hover: #EA580C;
    --bg-color: #F8FAFC;
    --card-bg: #FFFFFF;
    --text-main: #1E293B;
    --text-muted: #64748B;
    --border-color: #E2E8F0;
    --success: #10B981;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.language-switcher {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.language-switcher select {
    width: auto;
    min-width: 8.25rem;
    margin: 0;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    background: var(--card-bg);
    border-color: var(--border-color);
    color: var(--text-main);
    font-size: 0.9rem;
}

.language-switcher--floating {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1100;
    padding: 0.4rem 0.6rem;
    background: color-mix(in srgb, var(--card-bg) 94%, transparent);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

.glass-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.glass-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

.text-gradient {
    color: var(--primary);
}

input, select, textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    background: #F1F5F9;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    transition: all 0.3s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.2);
    transform: translateY(-1px);
}

button {
    background: var(--primary);
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px -1px rgba(249, 115, 22, 0.2);
}

button:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 8px -1px rgba(249, 115, 22, 0.3);
}

/* Modal Body Split Layout */
.modal-body-split {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 2rem;
}
@media (max-width: 768px) {
    .modal-body-split { grid-template-columns: 1fr; }
}

/* Input Wrapper with Icons */
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
}
.input-wrapper i {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
    font-size: 1.2rem;
}


.input-wrapper input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.8rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: #F1F5F9;
    color: var(--text-main);
    transition: all 0.3s ease;
}
.input-wrapper input:focus {
    background: #FFFFFF;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.2);
}
.form-group {
    margin-bottom: 0.5rem;
}
.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

/* Store Card Preview */
.store-card-preview-container {
    perspective: 1000px;
    margin-bottom: 1.5rem;
}
.store-card-preview-card {
    background: linear-gradient(135deg, #1E293B, #0F172A);
    border-radius: 16px;
    padding: 1.5rem;
    color: white;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease;
}
.store-card-preview-card:hover {
    transform: rotateX(5deg) rotateY(5deg);
}
.store-card-preview-card::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%);
    opacity: 0.5;
    pointer-events: none;
}
.store-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.store-card-title {
    font-size: 0.9rem;
    letter-spacing: 1px;
    color: #94A3B8;
}
.store-card-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.store-card-badge.unverified {
    background: rgba(239, 68, 68, 0.2);
    color: #F87171;
    border: 1px solid rgba(239, 68, 68, 0.4);
}
.store-card-badge.verified {
    background: rgba(16, 185, 129, 0.2);
    color: #34D399;
    border: 1px solid rgba(16, 185, 129, 0.4);
}
.store-card-name {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.store-card-info-row {
    font-size: 0.85rem;
    color: #CBD5E1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.store-card-info-row i {
    color: var(--primary);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: rgba(16, 185, 129, 0.1);
}

.btn-success {
    background: var(--success);
}
.btn-success:hover {
    background: #059669;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

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

th {
    color: var(--text-muted);
    font-weight: 500;
}

.nav-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
}

.flex-row {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.qr-container {
    text-align: center;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    margin-top: 1rem;
}

.qr-container img {
    max-width: 100%;
    height: auto;
}

#toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 1rem;
    background: var(--success);
    color: white;
    border-radius: 8px;
    display: none;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Responsive adjustments for Mobile screens */
@media (max-width: 768px) {
    .container {
        padding: 1rem 0.5rem;
    }
    
    .nav-bar {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
        text-align: center;
        padding: 1rem;
    }
    
    .flex-row {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }

    .language-switcher--floating {
        top: 0.5rem;
        right: 0.5rem;
    }
    
    .flex-row select, .flex-row button {
        width: 100% !important;
        margin-right: 0 !important;
    }

    .tabs-wrapper {
        display: flex;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.5rem;
        margin-bottom: 1.5rem;
        border-bottom: 2px solid var(--border-color);
        gap: 0.25rem;
    }
    
    .tab-btn {
        flex: 1 0 auto;
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
    
    .stat-grid {
        grid-template-columns: 1fr !important;
    }
    
    .chart-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }
    
    .modal-body-split {
        /* minmax(0, 1fr) thay cho 1fr: track 1fr có minimum ngầm là auto
           (= min-content), khiến bảng/nội dung rộng bên trong không cho track
           co nhỏ -> tràn ngang cả trang. minmax(0,...) gỡ minimum đó. */
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 1.5rem !important;
    }

    .modal-body-split > .modal-col-form {
        border-right: none !important;
        padding-right: 0 !important;
        padding-left: 0 !important;
        border-bottom: 1px dashed var(--border-color);
        padding-bottom: 2rem;
        margin-bottom: 1rem;
        min-width: 0 !important; /* cho phép ô grid co nhỏ hơn nội dung */
    }

    .modal-body-split > .modal-col-list {
        padding-left: 0 !important;
        min-width: 0 !important; /* cho phép ô grid co nhỏ hơn nội dung */
    }

    /* Mọi vùng bảng phải TỰ cuộn ngang trong khung của nó, thay vì đẩy rộng
       cả trang. min-width:0 để wrapper co theo cột grid đã hẹp. */
    .table-responsive,
    .table-responsive-product,
    .table-responsive-voucher {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        min-width: 0 !important;
    }

    /* Lưới an toàn: chặn tràn ngang ở cấp panel + container, để không nội dung
       nào đẩy lệch cả trang trên điện thoại. Bảng vẫn cuộn trong wrapper riêng
       (đã có overflow-x:auto ở trên), nên không mất dữ liệu. */
    .container { overflow-x: hidden; max-width: 100%; }
    .tab-content { overflow-x: hidden; }

    /* --- Vùng bấm dễ chạm bằng ngón tay trên điện thoại (~44px) --- */
    .tab-btn { min-height: 44px; }

    /* Nút thao tác nhỏ trong bảng (sửa / kho / bật-tắt / xóa) */
    .db-table td .btn-outline,
    .db-table td button {
        min-height: 40px;
        min-width: 40px;
    }

    /* input 16px: vừa dễ đọc, vừa tránh iOS tự phóng to khi focus */
    input, select, textarea {
        font-size: 16px;
    }

    #dashShopList, #whShopList, #vcShopList {
        width: 100%;
    }
    
    #dashShopList button, #whShopList button, #vcShopList button {
        flex: 1 1 calc(50% - 0.5rem);
        text-align: center;
    }
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 1rem;
}

.table-responsive table {
    width: 100%;
    min-width: 500px;
}

/* Extra Mobile Adjustments */
@media (max-width: 480px) {
    .language-switcher--auth + .login-container,
    .language-switcher--auth + .verify-container {
        height: auto;
        min-height: 100vh;
        padding-top: 4.75rem;
        padding-bottom: 1rem;
    }

    .login-box, .verify-box, .glass-card {
        padding: 1.25rem !important;
        margin: 1rem !important;
    }
    .otp-field {
        width: 2.5rem !important;
        height: 2.75rem !important; /* cao ~44px để dễ chạm; giữ rộng 40px cho 6 ô vừa hàng */
        font-size: 1.25rem !important;
    }
    .nav-bar h2 {
        font-size: 1.2rem;
    }
    .store-card-name {
        font-size: 1.25rem;
    }
}

/* In-flow utilities keep recovery/install controls away from transaction CTAs. */
.ui-tools { position: relative; flex: 0 0 auto; color: #1e293b; }
.ui-tools > summary { min-height: 44px; padding: .6rem .75rem; cursor: pointer; border: 1px solid #64748b; border-radius: .5rem; background: #fff; box-sizing: border-box; }
.ui-tools [data-ui-tools] { position: absolute; inset-inline-end: 0; top: 100%; z-index: 1400; width: min(19rem, 85vw); padding: .5rem; display: grid; gap: .5rem; background: #fff; color: #1e293b; border: 1px solid #64748b; border-radius: .5rem; box-shadow: 0 4px 16px #0002; }
.ui-tools [data-ui-tools] button { width: 100%; min-height: 44px; white-space: normal; background: #fff; color: #1e293b; border: 1px solid #64748b; }
.ui-tools :focus-visible { outline: 3px solid #1d4ed8; outline-offset: 2px; }
