/* ========================================
   RESET & BASE
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #1e3c72;
    --primary-light: #2a5298;
    --secondary-color: #667eea;
    --secondary-light: #764ba2;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --text-color: #333;
    --text-muted: #666;
    --border-color: #ddd;
    --bg-light: #f8f9fa;
    --shadow: 0 10px 30px rgba(0,0,0,0.2);
    --shadow-light: 0 5px 15px rgba(0,0,0,0.1);
    --radius: 10px;
    --radius-lg: 15px;
    --transition: all 0.3s ease;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    min-height: 100vh;
    padding: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ========================================
   CONTAINER
   ======================================== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 20px;
}

h1 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: clamp(1.5em, 5vw, 2.5em);
    word-wrap: break-word;
}

.subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 20px;
    font-size: clamp(0.85em, 2.5vw, 1.1em);
}

/* ========================================
   LOGIN SECTION
   ======================================== */
.login-container {
    max-width: 450px;
    width: 100%;
    margin: 20px auto;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: clamp(20px, 5vw, 40px);
}

.login-header {
    text-align: center;
    margin-bottom: 25px;
}

.login-header .icon {
    font-size: clamp(40px, 10vw, 60px);
    margin-bottom: 15px;
}

.login-header h2 {
    color: var(--primary-color);
    font-size: clamp(1.3em, 4vw, 1.8em);
    margin-bottom: 10px;
}

.login-header p {
    color: var(--text-muted);
    font-size: clamp(0.8em, 2.5vw, 0.95em);
}

.login-form .form-group {
    margin-bottom: 18px;
}

.login-form label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-color);
    font-weight: 600;
    font-size: clamp(0.85em, 2.5vw, 1em);
}

.login-form input {
    width: 100%;
    padding: clamp(12px, 3vw, 15px);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 16px; /* Prevent zoom on iOS */
    transition: var(--transition);
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 60, 114, 0.1);
}

.login-btn {
    width: 100%;
    padding: clamp(12px, 3vw, 15px);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: clamp(14px, 3.5vw, 18px);
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(30, 60, 114, 0.4);
}

.login-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.login-btn:active {
    transform: translateY(0);
}

.error-message {
    background: #ffe6e6;
    color: var(--danger-color);
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: none;
    text-align: center;
    font-size: 0.9em;
}

.error-message.show {
    display: block;
}

/* ========================================
   USER INFO BAR
   ======================================== */
.user-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--secondary-light) 100%);
    padding: clamp(12px, 3vw, 15px) clamp(15px, 4vw, 25px);
    border-radius: var(--radius);
    margin-bottom: 20px;
    color: white;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.user-info .avatar {
    font-size: clamp(24px, 6vw, 30px);
}

.user-info .username {
    font-weight: bold;
    font-size: clamp(0.85em, 2.5vw, 1.1em);
}

#sessionInfo {
    display: none;
}

.logout-btn {
    padding: clamp(8px, 2vw, 10px) clamp(12px, 3vw, 20px);
    background: rgba(255,255,255,0.2);
    color: white;
    border: 2px solid rgba(255,255,255,0.5);
    border-radius: 8px;
    font-size: clamp(11px, 2.5vw, 14px);
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.logout-btn:hover {
    background: white;
    color: var(--secondary-color);
}

.logout-btn:active {
    transform: scale(0.98);
}

/* ========================================
   SEARCH SECTION
   ======================================== */
.search-section {
    background: var(--bg-light);
    border-radius: var(--radius);
    padding: clamp(15px, 4vw, 30px);
    margin-bottom: 25px;
}

.search-section h2 {
    font-size: clamp(1.1em, 3.5vw, 1.4em);
    margin-bottom: 15px;
    color: var(--primary-color);
}

.search-box {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: clamp(12px, 3vw, 15px);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px; /* Prevent zoom on iOS */
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 60, 114, 0.1);
}

.search-type {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.radio-label {
    display: inline-flex;
    align-items: center;
    padding: 10px 15px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    font-size: clamp(0.8em, 2.5vw, 0.95em);
}

.radio-label:hover {
    border-color: var(--primary-color);
    background: #f0f4ff;
}

.radio-label input[type="radio"] {
    margin-right: 8px;
}

.radio-label input[type="radio"]:checked + span {
    font-weight: bold;
    color: var(--primary-color);
}

.btn {
    padding: clamp(12px, 3vw, 15px) clamp(25px, 5vw, 40px);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: clamp(14px, 3vw, 16px);
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(30, 60, 114, 0.3);
}

.btn:active {
    transform: translateY(0);
}

/* ========================================
   RESULTS SECTION
   ======================================== */
.results-section {
    display: none;
}

/* ========================================
   PROFILE CARD
   ======================================== */
.profile-card {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--secondary-light) 100%);
    border-radius: var(--radius-lg);
    padding: clamp(15px, 4vw, 30px);
    margin-bottom: 25px;
    color: white;
    box-shadow: var(--shadow);
}

.profile-header {
    display: flex;
    align-items: center;
    gap: clamp(15px, 4vw, 30px);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.profile-image {
    width: clamp(100px, 25vw, 150px);
    height: clamp(100px, 25vw, 150px);
    border-radius: 50%;
    border: 4px solid white;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(40px, 10vw, 60px);
    color: var(--secondary-color);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.profile-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.upload-btn {
    position: absolute;
    bottom: 5px;
    right: 5px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: clamp(30px, 8vw, 40px);
    height: clamp(30px, 8vw, 40px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(14px, 4vw, 20px);
    transition: var(--transition);
}

.upload-btn:hover {
    background: var(--primary-light);
    transform: scale(1.1);
}

.profile-info {
    flex: 1;
    min-width: 200px;
}

.profile-name {
    font-size: clamp(1.5em, 5vw, 2.5em);
    font-weight: bold;
    margin-bottom: 8px;
    word-wrap: break-word;
}

.profile-id {
    font-size: clamp(0.9em, 2.5vw, 1.2em);
    opacity: 0.9;
}

/* ========================================
   INFO GRID
   ======================================== */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.info-card {
    background: white;
    border-radius: var(--radius);
    padding: clamp(15px, 4vw, 25px);
    box-shadow: var(--shadow-light);
}

.info-card h3 {
    color: var(--primary-color);
    margin-bottom: 12px;
    font-size: clamp(1em, 3vw, 1.3em);
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 8px;
}

.info-row {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    gap: 5px;
}

.info-label {
    font-weight: bold;
    color: #555;
    min-width: 120px;
    flex-shrink: 0;
    font-size: clamp(0.85em, 2.5vw, 1em);
}

.info-value {
    color: var(--text-color);
    flex: 1;
    min-width: 100px;
    word-wrap: break-word;
    font-size: clamp(0.85em, 2.5vw, 1em);
}

/* ========================================
   VEHICLE SECTION
   ======================================== */
.vehicle-section {
    background: white;
    border-radius: var(--radius);
    padding: clamp(15px, 4vw, 25px);
    margin-top: 20px;
}

.vehicle-section h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: clamp(1.1em, 3.5vw, 1.5em);
}

.vehicle-card {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border-radius: var(--radius);
    padding: clamp(12px, 3vw, 20px);
    margin-bottom: 12px;
    color: white;
}

.vehicle-plate {
    font-size: clamp(1.2em, 4vw, 1.8em);
    font-weight: bold;
    margin-bottom: 8px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.vehicle-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
    gap: 8px;
    font-size: clamp(0.8em, 2.5vw, 1em);
}

/* ========================================
   OWNER CARD
   ======================================== */
.owner-card {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    border-radius: var(--radius-lg);
    padding: clamp(15px, 4vw, 25px);
    margin-bottom: 20px;
    color: white;
    box-shadow: var(--shadow);
}

.owner-card h3 {
    font-size: clamp(1.1em, 3.5vw, 1.5em);
    margin-bottom: 12px;
    border-bottom: 2px solid rgba(255,255,255,0.3);
    padding-bottom: 8px;
}

.owner-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
    gap: 12px;
}

.owner-info-item {
    background: rgba(255,255,255,0.15);
    padding: 10px 12px;
    border-radius: 8px;
}

.owner-info-item strong {
    display: block;
    font-size: clamp(0.75em, 2vw, 0.85em);
    opacity: 0.9;
    margin-bottom: 4px;
}

.owner-info-item span {
    font-size: clamp(0.9em, 2.5vw, 1.1em);
    font-weight: 600;
    word-wrap: break-word;
}

/* ========================================
   STATUS BADGES
   ======================================== */
.status-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: clamp(0.75em, 2vw, 0.9em);
    font-weight: bold;
}

.status-active {
    background: var(--success-color);
    color: white;
}

.status-temp {
    background: var(--warning-color);
    color: #333;
}

/* ========================================
   PERSON LINK
   ======================================== */
.person-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(30, 60, 114, 0.1);
    display: inline-block;
}

.person-link:hover {
    color: #fff;
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--secondary-light) 100%);
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
.hidden {
    display: none !important;
}

.no-data {
    text-align: center;
    padding: clamp(20px, 5vw, 40px);
    color: #999;
    font-size: clamp(1em, 3vw, 1.2em);
}

/* ========================================
   DOWNLOAD SECTION
   ======================================== */
.download-section {
    margin-top: 25px;
    padding: clamp(15px, 4vw, 20px);
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--secondary-light) 100%);
    border-radius: var(--radius-lg);
    text-align: center;
}

.download-section h3 {
    color: white;
    margin-bottom: 12px;
    font-size: clamp(0.95em, 3vw, 1.1em);
}

.download-section p {
    color: rgba(255,255,255,0.9);
    font-size: clamp(0.75em, 2.5vw, 0.85em);
    margin-bottom: 12px;
}

.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: clamp(10px, 3vw, 12px) clamp(15px, 4vw, 20px);
    background: white;
    border-radius: 8px;
    text-decoration: none;
    font-weight: bold;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    margin: 5px;
}

.download-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.dropdown {
    position: relative;
}

#downloadMenu {
    min-width: 200px;
}

#downloadMenu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    text-decoration: none;
    color: var(--text-color);
    border-bottom: 1px solid #eee;
    transition: background 0.2s;
}

#downloadMenu a:hover {
    background: #f5f5f5;
}

#downloadMenu a:last-child {
    border-bottom: none;
}

/* ========================================
   ADMIN BUTTONS
   ======================================== */
.admin-only {
    display: none;
}

/* ========================================
   NOTES SECTION
   ======================================== */
.notes-section {
    background: white;
    border-radius: var(--radius);
    padding: clamp(15px, 4vw, 25px);
    margin-top: 20px;
}

.note-card {
    background: var(--bg-light);
    border-radius: 8px;
    padding: clamp(12px, 3vw, 15px);
    margin-bottom: 10px;
    border-left: 4px solid var(--secondary-color);
}

/* ========================================
   FOOTER
   ======================================== */
footer {
    text-align: center;
    padding: clamp(15px, 4vw, 20px);
    margin-top: 25px;
    color: var(--text-muted);
    font-size: clamp(0.75em, 2.5vw, 0.9em);
    background: rgba(255,255,255,0.9);
    border-radius: var(--radius);
}

footer p {
    margin: 5px 0;
}

/* ========================================
   RESPONSIVE - TABLET
   ======================================== */
@media (max-width: 992px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 15px;
    }
    
    .user-bar {
        justify-content: center;
    }
    
    .user-bar > div {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .info-label {
        min-width: 100px;
    }
}

/* ========================================
   RESPONSIVE - MOBILE
   ======================================== */
@media (max-width: 768px) {
    body {
        padding: 8px;
    }
    
    .container {
        padding: 12px;
        border-radius: var(--radius);
    }
    
    /* User Bar Mobile */
    .user-bar {
        flex-direction: column;
        gap: 12px;
        padding: 12px;
    }
    
    .user-info {
        justify-content: center;
        width: 100%;
    }
    
    #sessionInfo {
        display: none !important;
    }
    
    .user-bar > div:last-child {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        width: 100%;
    }
    
    .logout-btn {
        padding: 8px 12px;
        font-size: 11px;
    }
    
    /* Profile Header Mobile */
    .profile-header {
        flex-direction: column;
        text-align: center;
    }
    
    .profile-image {
        margin: 0 auto;
    }
    
    .profile-info {
        width: 100%;
        text-align: center;
    }
    
    /* Search Box Mobile */
    .search-box {
        flex-direction: column;
    }
    
    .search-input {
        width: 100%;
        min-width: unset;
    }
    
    .btn {
        width: 100%;
    }
    
    /* Info Grid Mobile */
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .info-row {
        flex-direction: column;
        gap: 3px;
    }
    
    .info-label {
        min-width: unset;
        width: 100%;
    }
    
    .info-value {
        min-width: unset;
        width: 100%;
    }
    
    /* Login Mobile */
    .login-container {
        margin: 10px auto;
        padding: 20px;
        border-radius: var(--radius);
    }
    
    /* Download Section Mobile */
    .download-section > div {
        flex-direction: column !important;
    }
    
    .download-btn {
        width: 100%;
        max-width: 280px;
        justify-content: center;
    }
    
    /* Vehicle Info Mobile */
    .vehicle-info {
        grid-template-columns: 1fr;
    }
    
    .owner-info {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   RESPONSIVE - SMALL MOBILE
   ======================================== */
@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    
    .container {
        padding: 10px;
        border-radius: 8px;
    }
    
    h1 {
        font-size: 1.3em;
    }
    
    .subtitle {
        font-size: 0.8em;
    }
    
    .profile-image {
        width: 90px;
        height: 90px;
    }
    
    .profile-name {
        font-size: 1.4em;
    }
    
    .login-header .icon {
        font-size: 40px;
    }
    
    .logout-btn {
        padding: 6px 10px;
        font-size: 10px;
    }
    
    .info-card {
        padding: 12px;
    }
    
    .info-card h3 {
        font-size: 1em;
    }
    
    footer {
        font-size: 0.7em;
    }
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-download {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.01); }
}

.results-section {
    animation: fadeIn 0.3s ease;
}

.profile-card {
    animation: fadeIn 0.4s ease;
}

/* ========================================
   TOUCH IMPROVEMENTS
   ======================================== */
@media (hover: none) and (pointer: coarse) {
    .btn:hover,
    .logout-btn:hover,
    .download-btn:hover,
    .login-btn:hover {
        transform: none;
        box-shadow: inherit;
    }
    
    .btn:active,
    .logout-btn:active,
    .download-btn:active,
    .login-btn:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
    
    /* Larger tap targets for mobile */
    .btn, .logout-btn, .download-btn {
        min-height: 44px;
    }
    
    input, select {
        min-height: 44px;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
    body {
        background: white;
        padding: 0;
    }
    
    .container {
        box-shadow: none;
    }
    
    .user-bar,
    .search-section,
    .download-section,
    .logout-btn,
    .upload-btn,
    footer {
        display: none !important;
    }
}

/* ========================================
   CONTENT PROTECTION (chống sao chép / in ấn)
   Chỉ áp dụng khi html có class "content-protected"
   (JS tự động bỏ class này nếu người dùng là admin)
   ======================================== */
html.content-protected,
html.content-protected body {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

html.content-protected input,
html.content-protected textarea,
html.content-protected select,
html.content-protected [contenteditable="true"] {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

html.content-protected img {
    -webkit-user-drag: none;
}

@media print {
    html.content-protected body * {
        visibility: hidden !important;
    }
    html.content-protected body::after {
        content: "⚠️ Đã vô hiệu hóa in ấn để bảo vệ dữ liệu mật.";
        visibility: visible;
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        font-size: 22px;
        color: #c0392b;
        font-weight: bold;
    }
}

/* ========================================
   EDIT / LIST MODAL (chỉnh sửa, đã xóa, đã hết hạn...)
   ======================================== */
.edit-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 10000; justify-content: center; align-items: center; }
.edit-modal.show { display: flex; }
.edit-modal-content { background: white; border-radius: 15px; width: 92%; max-width: 760px; max-height: 92vh; overflow-y: auto; animation: slideIn 0.3s; color: #333; }
@keyframes slideIn { from { transform: translateY(-50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.edit-modal-header { padding: 20px 25px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; }
.edit-modal-header h3 { margin: 0; color: #333; }
.edit-modal-close { background: none; border: none; font-size: 1.5em; cursor: pointer; color: #999; }
.edit-modal-body { padding: 25px; color: #333; }
.edit-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 15px; }
.edit-form-group { margin-bottom: 5px; }
.edit-form-group.full-width { grid-column: 1 / -1; }
.edit-form-group label { display: block; margin-bottom: 8px; font-weight: 600; color: #555; }
.edit-form-group input, .edit-form-group textarea { width: 100%; padding: 11px 13px; border: 2px solid #e0e0e0; border-radius: 8px; font-size: 1em; box-sizing: border-box; }
.edit-form-group textarea { min-height: 76px; resize: vertical; }
.edit-form-group input:focus, .edit-form-group textarea:focus { outline: none; border-color: #667eea; }
.edit-modal-footer { padding: 15px 25px; border-top: 1px solid #eee; display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.btn-cancel, .btn-save, .btn-delete-citizen { padding: 10px 16px; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; }
.btn-cancel { background: #e0e0e0; color: #333; }
.btn-save { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; }
.btn-delete-citizen { margin-right: auto; background: #e74c3c; color: white; }
.edit-citizen-btn:hover, .btn-save:hover, .btn-delete-citizen:hover { transform: translateY(-1px); }

/* ========================================
   SCROLLBAR STYLES
   ======================================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-light);
}

/* ========================================
   SAFE AREA (iPhone X+)
   ======================================== */
@supports (padding: max(0px)) {
    body {
        padding-left: max(8px, env(safe-area-inset-left));
        padding-right: max(8px, env(safe-area-inset-right));
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }
}

/* ========================================
   MODAL STYLES
   ======================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 15px;
    backdrop-filter: blur(5px);
}

.modal-container {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.2em;
}

.modal-header button {
    background: none;
    border: none;
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.modal-header button:hover {
    opacity: 1;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(90vh - 150px);
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Form trong modal */
.modal-body fieldset {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 15px;
    margin-bottom: 15px;
}

.modal-body fieldset legend {
    padding: 0 10px;
    font-weight: bold;
    color: var(--primary-color);
}

.modal-body input,
.modal-body select,
.modal-body textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95em;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.modal-body input:focus,
.modal-body select:focus,
.modal-body textarea:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.modal-body label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-color);
}

/* Responsive cho modal */
@media (max-width: 600px) {
    .modal-container {
        max-width: 100%;
        margin: 10px;
        border-radius: var(--radius);
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .modal-body fieldset {
        padding: 10px;
    }
}

/* ========================================
   RESPONSIVE - Ép các lưới 2 cột inline (grid-template-columns: 1fr 1fr)
   xuống 1 cột trên điện thoại/máy tính bảng nhỏ
   ======================================== */
@media (max-width: 768px) {
    [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
    
    [style*="grid-column: 1 / -1"] {
        grid-column: 1 / -1 !important;
    }
}
