/* --- CÀI ĐẶT CHUNG & BỐ CỤC --- */
body {
    font-family: Arial, sans-serif;
    background-color: #f4f7f6;
    color: #333;
    margin: 0;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: auto;
    background: #fff;
    padding: 20px 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

h1, h2, h3 {
    color: #0056b3;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

h1 { 
    text-align: center;
    font-size: 1.8em;
}

hr {
    border: none;
    border-top: 1px solid #eee;
    margin: 40px 0;
}

/* --- THANH ĐIỀU HƯỚNG --- */
.nav-links {
    text-align: center;
    margin-bottom: 25px;
    font-size: 1.1em;
    flex-wrap: wrap;
    display: flex;
    justify-content: center;
    gap: 5px 15px;
}

.nav-links a {
    text-decoration: none;
    color: #007bff;
    padding: 5px;
}

.nav-links a:hover {
    text-decoration: underline;
}

/* --- FORM & NÚT BẤM --- */
.form-container, .table-container, .filter-container {
    margin-bottom: 30px;
}

form input[type="text"],
form input[type="number"],
form input[type="date"],
form input[type="email"],
form input[type="password"],
form input[type="url"],
form select {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

.radio-group {
    margin-bottom: 15px;
}

.radio-group label {
    margin-right: 20px;
}

button[type="submit"] {
    background-color: #007bff;
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    width: 100%;
    transition: background-color 0.2s;
}

button[type="submit"]:hover {
    background-color: #0056b3;
}

/* --- BẢNG BIỂU --- */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

table th, table td {
    border: 1px solid #ddd;
    padding: 12px;
    text-align: left;
    vertical-align: middle;
}

table th {
    background-color: #f2f2f2;
    color: #333;
}

table tr:nth-child(even) { background-color: #f9f9f9; }
table tr:hover { background-color: #f1f1f1; }

.thu { color: #28a745; font-weight: bold; }
.chi { color: #dc3545; font-weight: bold; }
.balance { font-weight: bold; }

/* --- CÁC NÚT HÀNH ĐỘNG --- */
.delete-btn, .action-btn-lock, .action-btn-edit, .action-btn-disabled {
    display: inline-block;
    color: #fff;
    padding: 5px 10px;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9em;
    text-align: center;
    margin-bottom: 5px;
}
.delete-btn { background-color: #dc3545; }
.delete-btn:hover { background-color: #c82333; }

.action-btn-edit { background-color: #17a2b8; }
.action-btn-edit:hover { background-color: #138496; }

.action-btn-lock { background-color: #ffc107; color: #212529; }
.action-btn-lock:hover { background-color: #e0a800; }

.action-btn-disabled { background-color: #6c757d; cursor: not-allowed; }

/* --- ĐỊNH DẠNG TRẠNG THÁI --- */
.status-locked, .status-active {
    padding: 3px 8px;
    border-radius: 12px;
    color: white;
    font-size: 0.85em;
    font-weight: bold;
}
.status-locked { background-color: #dc3545; }
.status-active { background-color: #28a745; }

/* --- TRANG ĐĂNG NHẬP --- */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    padding: 30px;
}
.error {
    color: #dc3545;
    margin-bottom: 15px;
    text-align: center;
}

/* --- DASHBOARD --- */
/* Thẻ thống kê */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}
.card {
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    text-align: center;
    border-left: 5px solid #007bff;
}
.card h3 {
    margin-top: 0;
    font-size: 1.1em;
    color: #6c757d;
    border-bottom: none;
}
.card p {
    font-size: 1.8em;
    margin-bottom: 0;
}
.card:nth-child(1) { border-color: #17a2b8; } /* VND */
.card:nth-child(2) { border-color: #0056b3; } /* PayPal */
.card:nth-child(3) { border-color: #28a745; } /* Tổng tài sản */

/* Vùng chứa biểu đồ */
.chart-container {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    margin-top: 20px;
}
.chart-container h3 {
    text-align: center;
    margin-top: 0;
}

/* Bộ lọc */
.filter-container {
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}
.filter-container h2 {
    margin-top: 0;
    border-bottom: none;
    font-size: 1.2em;
}
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    align-items: end;
}
.filter-grid label {
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 0.9em;
}
.filter-actions {
    margin-top: 15px;
    display: flex;
    gap: 10px;
}
.filter-actions button {
    width: auto;
    padding: 10px 20px;
}
.clear-filter-btn {
    display: inline-block;
    background-color: #6c757d;
    color: white;
    padding: 10px 20px;
    text-decoration: none;
    border-radius: 4px;
    font-size: 16px;
    border: none;
    cursor: pointer;
}
.clear-filter-btn:hover { background-color: #5a6268; }

/* Bộ lọc nhanh */
.quick-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}
.qf-btn {
    display: inline-block;
    padding: 8px 15px;
    background-color: #e9ecef;
    color: #495057;
    text-decoration: none;
    border-radius: 20px;
    font-size: 0.9em;
    border: 1px solid #dee2e6;
    transition: all 0.2s ease-in-out;
}
.qf-btn:hover {
    background-color: #ced4da;
    border-color: #adb5bd;
}
.qf-btn.active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
    font-weight: bold;
}


/* --- TRANG PAYPAL --- */
.exchange-rate {
    text-align: center;
    font-size: 1.1em;
    margin: -15px 0 25px 0;
    padding: 10px;
    background-color: #e9f5ff;
    border: 1px solid #bde0fe;
    border-radius: 5px;
}

/* --- TRANG CHUYỂN TIỀN --- */
.tab-container {
    display: flex;
    border-bottom: 2px solid #ccc;
    margin-bottom: 20px;
}
.tab-link {
    padding: 10px 20px;
    cursor: pointer;
    border: 1px solid transparent;
    border-bottom: none;
    background-color: #f1f1f1;
    font-size: 1.1em;
}
.tab-link.active {
    background-color: white;
    border-color: #ccc;
    border-bottom: 2px solid white;
    position: relative;
    top: 1px;
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* --- RESPONSIVE CHO GIAO DIỆN MOBILE --- */
@media (max-width: 768px) {
    body {
        padding: 10px 5px;
    }

    .container {
        padding: 15px;
    }

    h1 {
        font-size: 1.5em;
    }

    /* Xử lý cho bảng dữ liệu - phần quan trọng nhất */
    table {
        border: 0;
    }

    table thead {
        /* Ẩn tiêu đề của bảng */
        border: none;
        clip: rect(0 0 0 0);
        height: 1px;
        margin: -1px;
        overflow: hidden;
        padding: 0;
        position: absolute;
        width: 1px;
    }
    
    table tr {
        /* Mỗi hàng sẽ là một khối riêng biệt */
        display: block;
        margin-bottom: 15px;
        border: 1px solid #ddd;
        border-radius: 5px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }
    
    table td {
        /* Các ô sẽ xếp chồng lên nhau */
        display: block;
        text-align: right; /* Căn phải nội dung */
        font-size: 1em;
        border-bottom: 1px dotted #ccc;
    }

    table td::before {
        /* Hiển thị lại tiêu đề của cột ở bên trái */
        content: attr(data-label);
        float: left;
        font-weight: bold;
        text-transform: uppercase;
        color: #333;
    }

    table td:last-child {
        border-bottom: 0;
    }
}


/* --- INVOICE STYLES --- */
.invoice-container {
    background: #fff;
    border: 1px solid #ddd;
    padding: 30px;
    margin: 20px auto;
    max-width: 800px;
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 40px;
}

.invoice-header .company-details h2 {
    margin-top: 0;
    border: none;
}

.invoice-header textarea {
    width: 250px;
    height: 80px;
    border: 1px solid #eee;
    padding: 5px;
}

.invoice-meta .meta-item {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.invoice-meta label {
    font-weight: bold;
    margin-right: 10px;
}
.invoice-meta input {
    width: 150px;
    border: 1px solid #eee;
    text-align: right;
}

.customer-details {
    margin-bottom: 40px;
}

#itemsTable {
    width: 100%;
    border-collapse: collapse;
}

#itemsTable th {
    background-color: #f2f2f2;
    text-align: left;
    padding: 10px;
}

#itemsTable td {
    padding: 10px;
    border-bottom: 1px solid #eee;
}

#itemsTable input {
    width: 90%;
    border: 1px solid #ddd;
    padding: 8px;
}

#itemsTable .item-total {
    text-align: right;
    font-weight: bold;
}

#addItemBtn {
    margin-top: 15px;
    background-color: #28a745;
    width: auto;
    font-size: 14px;
    padding: 8px 15px;
}
#addItemBtn:hover {
    background-color: #218838;
}

.invoice-summary {
    margin-top: 30px;
    margin-left: auto;
    width: 300px;
}

.invoice-summary .summary-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
}
.invoice-summary .summary-item.total {
    font-size: 1.2em;
    font-weight: bold;
    border-top: 2px solid #333;
}
.invoice-summary input {
    width: 60px;
    text-align: right;
    border: 1px solid #ddd;
}
.invoice-footer {
    margin-top: 40px;
    text-align: center;
}
.invoice-footer button {
    width: auto;
    padding: 15px 30px;
    font-size: 18px;
}

/* --- PRINT STYLES --- */
@media print {
    body {
        background-color: #fff;
        padding: 0;
        margin: 0;
    }
    .no-print, .nav-links, .form-container:not(.invoice-container) {
        display: none !important;
    }
    .container {
        box-shadow: none;
        border: none;
        padding: 0;
        max-width: 100%;
    }
    textarea, input {
        border: none !important;
        background-color: #fff !important;
        resize: none;
    }
    textarea {
        width: 100% !important;
    }
}
/* --- CSS cho chế độ chụp ảnh hóa đơn --- */
.is-capturing input,
.is-capturing textarea {
    border: none !important;
    box-shadow: none !important;
    padding: 8px 0 !important; /* Điều chỉnh để giống văn bản thường */
    background-color: transparent !important;
    resize: none; /* Vô hiệu hóa việc thay đổi kích thước textarea */
}

.is-capturing .no-print {
    display: none !important; /* Ẩn các nút "Xóa" */
}