/**
 * /css/style.css
 * Phiên bản CSS cơ bản, tập trung vào chức năng và layout chính.
 * Loại bỏ các style phức tạp gần đây, giữ lại cuộn ngang cho bảng.
 */

/* === Reset Cơ bản & Global Styles === */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: sans-serif; line-height: 1.6; background-color: #f8f9fa; color: #212529; }
h1, h2, h3, h4, h5, h6 { margin-top: 0; margin-bottom: 0.75rem; font-weight: 500; }
h1 { font-size: 2rem; margin-bottom: 1.5rem; } h2 { font-size: 1.75rem; margin-bottom: 1rem; }
p { margin-top: 0; margin-bottom: 1rem; }
a { color: #007bff; text-decoration: none; } a:hover { color: #0056b3; text-decoration: underline; }
hr { margin-top: 1rem; margin-bottom: 1rem; border: 0; border-top: 1px solid #dee2e6; }
pre { background-color: #f1f1f1; border: 1px solid #ddd; padding: 10px; white-space: pre-wrap; word-wrap: break-word; font-family: monospace; overflow: auto; }
code { font-family: monospace; background-color: #eee; padding: 2px 4px; border-radius: 3px;}
.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; }

/* === Layout Chính === */
.site-header { background-color: #ffffff; padding: 10px 20px; border-bottom: 1px solid #dee2e6; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 1px 2px rgba(0,0,0,.05); position: sticky; top: 0; z-index: 1020; }
.site-title a { text-decoration: none; color: #343a40; font-size: 1.4em; font-weight: bold; }
.main-nav ul { list-style: none; padding: 0; margin: 0; display: flex; }
.main-nav li { margin-left: 15px; }
.main-nav a { text-decoration: none; color: #007bff; padding: 5px 0; }
.main-nav a:hover { color: #0056b3; }
.mobile-nav-toggle { display: none; /* Ẩn nút mobile mặc định */ background: none; border: none; font-size: 1.5rem; cursor: pointer;}

.main-content { padding: 20px; background-color: #ffffff; min-height: calc(100vh - 150px); margin: 15px; border-radius: 5px; }
.site-footer { text-align: center; padding: 15px; margin-top: 25px; background-color: #e9ecef; border-top: 1px solid #dee2e6; color: #6c757d; font-size: 0.9em; }

/* === Thông báo === */
.message { padding: 1rem; margin-bottom: 1rem; border-radius: .25rem; border: 1px solid transparent; }
.message ul { margin: 5px 0 0 0; padding-left: 20px; text-align: left; }
.message.error, .db-error-message { background-color: #f8d7da; color: #721c24; border-color: #f5c6cb; }
.message.success { background-color: #d4edda; color: #155724; border-color: #c3e6cb; }
.message.warning { background-color: #fff3cd; color: #856404; border-color: #ffeeba; }
.message.info { background-color: #d1ecf1; color: #0c5460; border-color: #bee5eb; }
.expiry-warning { background-color: #fff3cd; color: #856404; border: 1px solid #ffeeba; padding: .75rem 1rem; margin-bottom: 1rem; border-radius: .25rem; text-align: center; font-weight: bold; }


/* === Form Cơ bản === */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: .4rem; font-weight: bold; }
.form-group input[type="text"], .form-group input[type="email"], .form-group input[type="tel"],
.form-group input[type="password"], .form-group input[type="number"], .form-group input[type="date"],
.form-group input[type="url"], .form-group select, .form-group textarea {
    display: block; width: 100%; padding: .45rem .75rem; font-size: 1rem; line-height: 1.5;
    color: #495057; background-color: #fff; border: 1px solid #ced4da; border-radius: .25rem;
    box-sizing: border-box; transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}
.form-group textarea { height: auto; min-height: 100px; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: #80bdff; outline: 0; box-shadow: 0 0 0 .2rem rgba(0,123,255,.25); }
.form-group button[type="submit"], .button, .btn-filter, .btn-reset, .backup-button {
    display: inline-block; font-weight: 600; color: #fff; text-align: center; vertical-align: middle; cursor: pointer; user-select: none; background-color: #007bff; border: 1px solid #007bff; padding: .5rem 1rem; font-size: 1rem; line-height: 1.5; border-radius: .25rem; text-decoration: none; transition: background-color .15s ease-in-out;
}
.form-group button[type="submit"]:hover, .button:hover, .btn-filter:hover, .backup-button:hover { background-color: #0056b3; border-color: #0056b3; }
.btn-reset { background-color: #6c757d; border-color: #6c757d; } .btn-reset:hover { background-color: #5a6268; border-color: #545b62; }
.form-note { font-size: 0.85em; color: #6c757d; margin-top: .3rem; }
.warning-text { color: #c82333; font-weight: 500; }
.radio-group label { margin-right: 15px; font-weight: normal; } .radio-group input[type="radio"] { margin-right: 5px;}
.cancel-link { margin-left: 15px; font-size: 0.9em;}
.hidden-field { position: absolute !important; left: -9999px;}


/* === Form Login/Register/Forgot === */
.register-form-container, .login-form, .forgot-password-form { max-width: 450px; margin: 40px auto; padding: 30px; border: 1px solid #dee2e6; border-radius: 6px; background-color: #fff; }
.register-form-container h2, .login-form h2, .forgot-password-form h2 { text-align: center; margin-bottom: 25px; font-weight: 600; }
.login-link { text-align: center; margin-top: 20px; font-size: 0.9em; }


/* === Bảng Dữ liệu (Admin) - Đảm bảo cuộn ngang === */
.table-wrapper {
    overflow-x: auto;           /* LUÔN BẬT CUỘN NGANG */
    -webkit-overflow-scrolling: touch; /* Cuộn mượt hơn trên iOS */
    margin-top: 15px;
    border: 1px solid #dee2e6;  /* Viền cho wrapper */
    border-radius: 4px;
    width: 100%; /* Đảm bảo wrapper chiếm đủ không gian */
}
.user-table, .log-table, .request-table {
    width: 100%;                /* Bảng chiếm hết wrapper */
    border-collapse: collapse;
    margin: 0;                  /* Bỏ margin của table */
    border: none;               /* Bỏ border của table */
    font-size: 0.9em;
}
.user-table th, .user-table td,
.log-table th, .log-table td,
.request-table th, .request-table td {
    border-bottom: 1px solid #dee2e6; /* Chỉ kẻ ngang */
    padding: 0.6rem 0.75rem;   /* Padding vừa phải */
    text-align: left;
    vertical-align: middle;
    /*white-space: nowrap; */     /* QUAN TRỌNG: Giữ nội dung trên 1 dòng để cuộn */
}
.user-table tbody tr:last-child td,
.log-table tbody tr:last-child td,
.request-table tbody tr:last-child td {
    border-bottom: none; /* Bỏ kẻ dòng cuối */
}
.user-table thead th, .log-table thead th, .request-table thead th {
    background-color: #f1f3f5; /* Nền header nhẹ */
    font-weight: 600;
    border-bottom-width: 2px;
    position: sticky; top: 0; z-index: 1; /* Giữ header khi cuộn dọc */
}
.user-table tbody tr:hover, .log-table tbody tr:hover, .request-table tbody tr:hover {
    background-color: #f1f3f5; /* Màu hover nhẹ */
}
/* Cho phép MỘT SỐ cột thật sự cần thiết được xuống dòng */
.user-table td:nth-child(3), /* Họ tên */
.log-table td:nth-child(4)  /* Chủ đề email */
{
    white-space: normal; /* Cho phép wrap */
    min-width: 150px;    /* Đặt chiều rộng tối thiểu */
}
.action-links { text-align: center; } /* Căn giữa nút action */


/* === Các Thành phần Admin khác (Style Cơ bản) === */
.total-count { margin-top: 15px; margin-bottom: 10px; font-weight: bold; }
.pagination { margin-top: 20px; text-align: center; padding-bottom: 10px; }
.pagination a, .pagination span { display: inline-block; padding: 5px 10px; margin: 0 2px; border: 1px solid #ccc; text-decoration: none; color: #007bff; border-radius: 3px; }
.pagination span.current { background-color: #007bff; color: white; border-color: #007bff; }
.pagination span.disabled { color: #ccc; border-color: #eee;}
.filter-toggle-button { margin-bottom: 15px; padding: 8px 12px; background-color: #6c757d; border: none; color: white; cursor: pointer; border-radius: 4px; }
.filter-toggle-button i { margin-right: 5px; }
.filter-form { background-color: #f8f9fa; padding: 15px; border: 1px solid #e3e6f0; border-radius: 5px; margin-bottom: 20px; display: none; /* **Ẩn mặc định** */ grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 15px; align-items: flex-end; margin-top: 15px; }
.filter-form.active { display: grid; /* **Hiện khi có class active** */ }
.filter-form .form-group { margin-bottom: 0; }
.filter-form label { font-size: 0.85em; margin-bottom: 3px;}
.filter-form .action-group { grid-column: -1 / 1; }
/* Dashboard */
.dashboard-stats { display: flex; flex-wrap: wrap; gap: 15px; margin-bottom: 25px; }
.stat-box { flex: 1 1 180px; background-color: #f1f3f5; padding: 15px; border-radius: 4px; text-align: center; border: 1px solid #dee2e6; }
.stat-box h3 { font-size: 1em; color: #555; margin-bottom: 8px;}
.stat-box .number { font-size: 2em; font-weight: bold; display: block; }
/* Settings */
.settings-form fieldset { margin-bottom: 25px; border: 1px solid #e2e8f0; padding: 20px; border-radius: 4px;}
.settings-form legend { font-weight: 600; font-size: 1.2em; padding: 0 5px; color: #333; margin-bottom: 15px;}
.placeholders { font-size: 0.85em; background-color: #e7f3ff; border: 1px solid #b3d7ff; padding: 8px 10px; border-radius: 4px; margin-top: 5px; word-break: break-word;}
/* Tabs - Basic styles, rely on JS to add 'active' */
.nav-tabs { display: flex; flex-wrap: wrap; list-style: none; padding-left: 0; margin-bottom: 1rem; border-bottom: 1px solid #dee2e6;}
.nav-tabs .nav-item { margin-bottom: -1px; }
.nav-tabs .nav-link { display: block; padding: .5rem 1rem; border: 1px solid transparent; border-top-left-radius: .25rem; border-top-right-radius: .25rem; color: #007bff; cursor: pointer; background: none;}
.nav-tabs .nav-link:hover, .nav-tabs .nav-link:focus { border-color: #e9ecef #e9ecef #dee2e6; color: #0056b3; }
.nav-tabs .nav-link.active { color: #495057; background-color: #fff; border-color: #dee2e6 #dee2e6 #fff; font-weight: bold;}
.tab-content > .tab-pane { display: none; padding-top: 1rem; } /* Ẩn pane không active */
.tab-content > .tab-pane.active { display: block; } /* Hiện pane active */


/* === Style Trạng thái & Icon Đặc biệt === */
.status-pending { color: #fd7e14; font-weight: bold; } .status-approved { color: #28a745; font-weight: bold;} .status-rejected { color: #dc3545; }
.locked-status { color: #dc3545; font-weight:bold; } .active-status { color: #28a745; } .inactive-status { color:#6c757d; font-style: italic; }
.expired-note { color: #dc3545; font-weight: bold; font-size: 0.9em; } .status-sent { color: green; font-weight: bold; } .status-failed { color: red; }
.plain-password { color:red; font-family: monospace; font-size: 0.9em; background-color: #fff0f0; padding: 1px 3px; border: 1px dashed red; }
.checkbox-col input { vertical-align: middle; cursor: pointer; margin: 0; }
#pending-count-badge.visible-badge { background-color: #dc3545; /* ... */ } #pending-count-badge.hidden-badge { display: none; }

/* === Trang Liên hệ & Backup (Cơ bản) === */
.contact-container { display: flex; flex-wrap: wrap; gap: 20px; } .contact-info, .contact-form-section { flex: 1; min-width: 280px; }
.social-links a { margin-right: 10px; font-size: 1.5em; color: #6c757d;} .social-links a:hover { color: #007bff;}
.backup-warning { border: 1px solid #ffc107; background-color: #fff3cd; color: #856404; padding: 15px; border-radius: 5px; margin-bottom: 20px; }
.backup-options label { display: block; margin-bottom: 10px; cursor: pointer; }
.backup-options input[type=radio] { margin-right: 5px; } .option-desc { font-size: 0.9em; color: #666;}
.backup-list ul { list-style: none; padding: 0; }
.backup-list li { background-color: #f8f9fa; border: 1px solid #dee2e6; padding: 8px 12px; margin-bottom: 5px; border-radius: 4px; font-size: 0.9em; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 5px;}
.backup-list .file-info { display: flex; align-items: center; gap: 8px; } .backup-list .file-meta { white-space: nowrap; color: #6c757d; font-size: 0.9em; }
.restore-button { background-color: #dc3545 !important; /* ... */ }


/* === Responsive Cơ bản === */
@media (max-width: 768px) {
    .site-header { flex-direction: row; align-items: center; padding: 8px 15px; } /* Giữ lại trên 1 hàng */
    .mobile-nav-toggle { display: block; } /* Hiện nút hamburger */
    .main-nav { width: auto; } /* Nav không chiếm hết width */
    .main-nav ul { display: none; flex-direction: column; width: 100%; background-color: #fff; position: absolute; top: 100%; left: 0; box-shadow: 0 4px 6px rgba(0,0,0,0.1); border-top: 1px solid #e2e8f0; padding: 5px 0; z-index: 999; }
    .main-nav ul.mobile-active { display: flex; }
    .main-nav li { margin-left: 0; width: 100%; }
    .main-nav a { padding: 10px 20px; display: block; border-bottom: 1px solid #f1f1f1; }
    .main-nav li:last-child a { border-bottom: none; }

    .main-content { margin: 10px; padding: 15px; }
    .filter-form { grid-template-columns: 1fr 1fr; gap: 10px; }
    .filter-form .action-group { grid-column: span 2; }
    .user-table th, .user-table td, .log-table th, .log-table td, .request-table th, .request-table td { padding: .5rem .6rem; font-size: 0.85em; }
    .action-links { white-space: normal; } /* Cho phép nút action xuống dòng */
    .contact-container { flex-direction: column; }
}

@media (max-width: 576px) {
     body { font-size: 14px; } /* Giảm font body */
     h1 { font-size: 1.5rem; } h2 { font-size: 1.3rem; }
     .site-title a { font-size: 1.3em; }
     .main-content { padding: 10px; }
     .filter-form { grid-template-columns: 1fr; } /* 1 cột */
     .filter-form .action-group { flex-direction: column; }
     .filter-form button, .filter-form a.btn-reset { width: 100%; margin-left: 0; }
     .filter-form a.btn-reset { margin-top: 5px; }
     .user-table, .log-table, .request-table { font-size: 0.8em; } /* Chữ bảng nhỏ hơn */
     .user-table th, .user-table td, .log-table th, .log-table td, .request-table th, .request-table td { padding: .4rem .5rem; }
     .pagination a, .pagination span { padding: 3px 7px; font-size: 0.8em; }
     .nav-tabs { flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; } /* Tab cuộn ngang */
     .tab-content > .tab-pane { padding: 1rem 0.5rem; }
}