/* GLOBAL STYLES & FONT */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(180deg, #F0F4F8 0%, #D9E2F2 100%);
    margin: 0;
    padding: 20px;
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 10px;
}

h1 {
    font-size: 2.5em;
    background: linear-gradient(45deg, #1A73E8, #4CAF50, #F4B400);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

h2 {
    color: #1A73E8;
    margin-top: 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
    font-size: 1.5em;
}

.card {
    background-color: white;
    padding: 25px;
    margin-bottom: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* FORM STYLES */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #555;
    font-weight: 600;
    font-size: 0.9em;
}

input[type="text"],
input[type="number"],
input[type="date"],
select {
    padding: 10px 10px;
    width: 100%;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 16px; /* FIX LỖI ZOOM MOBILE */
    box-sizing: border-box;
    transition: border-color 0.2s;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
select:focus {
    border-color: #1A73E8;
    outline: none;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 15px;
}

button {
    padding: 10px 18px;
    background-color: #1A73E8;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
    font-weight: 600;
    font-size: 1em;
}

button:hover {
    background-color: #155bb5;
}

button:active {
    transform: scale(0.98);
}

.reset-button {
    background-color: #F04770;
}

.reset-button:hover {
    background-color: #d13c60;
}

/* TABLE STYLES */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

th, td {
    padding: 12px 8px;
    text-align: center;
    border: 1px solid #eee;
    font-size: 1em;
}

th {
    background-color: #4CAF50;
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

tr:nth-child(even) {
    background-color: #f7f7f7;
}

tr:hover {
    background-color: #eef;
}

/* CỘT CÓ THỂ CHỈNH SỬA */
td[contenteditable="true"] {
    cursor: text;
    background-color: #fffde7;
    border-radius: 3px;
    font-size: 16px; /* FIX LỖI ZOOM MOBILE */
    min-width: 100px; /* Đảm bảo ô đủ rộng */
}

/* SUMMARY & STATS */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
}

.summary-grid > div {
    background-color: #f9f9f9;
    padding: 12px;
    border-radius: 5px;
    border-left: 5px solid #1A73E8;
    font-size: 0.95em;
    font-weight: 500;
}

.summary-grid i {
    color: #1A73E8;
    margin-right: 5px;
}

.summary-value {
    font-weight: bold;
    font-size: 1.1em;
    margin-left: 5px;
}

/* EXCEL CONTROLS */
#excelControls {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
}

.export-group, .import-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin: 5px 0;
}

.export-group input[type="number"] {
    width: 80px;
}

.import-group input[type="file"] {
    flex-grow: 1;
}

/* STATUS MESSAGE (CHUYỂN THÀNH TOAST) */
#statusMessage {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    margin-bottom: 0;
    border-radius: 8px;
    text-align: left;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000; /* Đảm bảo nằm trên mọi thứ */
    transition: all 0.5s ease-in-out;
    opacity: 0;
    transform: translateX(100%);
    display: block !important; /* Luôn hiển thị block, dùng opacity/transform để ẩn/hiện */
}

#statusMessage.visible {
    opacity: 1;
    transform: translateX(0);
}

.success {
    background-color: #e8f5e9;
    color: #4CAF50;
    border-left: 5px solid #4CAF50;
}
.error {
    background-color: #fee;
    color: #ff4444;
    border-left: 5px solid #ff4444;
}


/* CUSTOM CLASSES */
.positive {
    color: #4CAF50 !important;
    font-weight: bold;
}

.negative {
    color: #ff4444 !important;
    font-weight: bold;
}

.capital-deposit {
    color: #8A2BE2 !important; /* Màu tím */
    font-weight: bold;
}

.capital-withdrawal {
    color: #F78C6A !important; /* Màu cam/đỏ nhạt */
    font-weight: bold;
}

.delete-btn {
    background-color: #ff4444;
    padding: 5px 10px;
}

.delete-btn:hover {
    background-color: #cc0000;
}

.warning-note {
    text-align: center;
    color: #777;
    margin-top: 20px;
    font-size: 0.9em;
}

.call-to-action-btn {
    padding: 12px 25px;
    background-color: #F4B400;
    color: #333;
    border-radius: 25px;
    font-size: 1.1em;
    margin: 20px 0;
}
.call-to-action-btn:hover {
    background-color: #d89f00;
}

/* PHÂN TRANG */
#pagination-controls {
    text-align: center;
    padding: 15px 0 5px 0;
}

/* RESPONSIVE DESIGN */
@media screen and (max-width: 900px) {
    .summary-grid {
        grid-template-columns: 1fr;
    }
}

@media screen and (max-width: 768px) {
    body {
        padding: 10px;
    }

    h1 {
        font-size: 2em;
    }

    .card {
        padding: 15px;
    }

    .form-actions button {
        width: 100%;
    }

    #excelControls {
        flex-direction: column;
        align-items: stretch;
    }

    .export-group, .import-group {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }
    
    .export-group input[type="number"] {
        width: 100%;
    }

    /* Bảng cuộn ngang (Cải tiến để đảm bảo hoạt động) */
    #transactionList {
        overflow-x: auto;
    }
    table {
        min-width: 650px; /* Đảm bảo bảng có độ rộng tối thiểu để kích hoạt cuộn ngang */
    }
    th, td {
        white-space: nowrap; /* Đảm bảo nội dung không bị ngắt dòng */
        padding: 10px 8px; /* Giảm padding một chút */
    }

    /* responsive: trên mobile, toast nằm ở giữa dưới */
    #statusMessage {
        top: auto;
        bottom: 20px;
        left: 50%;
        right: auto;
        transform: translateX(calc(-50% + 100%));
        width: 80%;
        text-align: center;
    }
    #statusMessage.visible {
        transform: translateX(-50%);
    }
}
