:root {
    --primary-color: #d32f2f; /* Red Tet */
    --secondary-color: #fbc02d; /* Yellow Tet */
    --success-color: #388e3c; /* Green */
    --danger-color: #d32f2f;
    --text-color: #333;
    --bg-color: #f5f5f5;
    --card-bg: #ffffff;
    --border-radius: 8px;
    --shadow: 0 4px 6px rgba(0,0,0,0.1);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
}

header {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
}

nav a {
    color: white;
    text-decoration: none;
    margin-left: 1rem;
    font-weight: bold;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    transition: background-color 0.2s;
}

nav a:hover, nav a.active {
    background-color: rgba(255, 255, 255, 0.2);
    color: var(--secondary-color);
}

main {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    text-align: center;
    padding: 2rem;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: bold;
    margin: 0.5rem 0;
}

.stat-label {
    color: #666;
    font-size: 1.1rem;
}

.text-success { color: var(--success-color); }
.text-danger { color: var(--danger-color); }

button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1rem;
    transition: transform 0.1s;
}

button:hover {
    filter: brightness(1.1);
}

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

button.secondary {
    background-color: var(--secondary-color);
    color: #333;
}

input, select {
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 1rem;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 1rem;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
}

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

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background-color: #f9f9f9;
    font-weight: 600;
}

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

.hidden {
    display: none !important;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-group {
    flex: 1;
}

.action-btn {
    padding: 0.5rem;
    margin-right: 0.5rem;
    font-size: 0.9rem;
}

.remove-btn {
    background-color: #ff5252;
}

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 500px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.close {
    cursor: pointer;
    font-size: 1.5rem;
}

/* --- New Styles for Daily View --- */
.daily-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.day-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid transparent;
}

.day-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.1);
    border-color: var(--secondary-color);
}

.day-card.today {
    background: #fff8e1; /* Light yellow */
    border: 2px solid var(--secondary-color);
    position: relative;
}

.day-card.today::after {
    content: 'Hôm nay';
    position: absolute;
    top: -10px;
    right: 10px;
    background: var(--primary-color);
    color: white;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
}

.day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.5rem;
}

.day-date {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--primary-color);
}

.day-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: #555;
    margin-top: 10px;
}

.day-total {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--success-color);
    display: block;
    margin-top: 5px;
}

/* Detail View Styles */
.detail-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.back-btn {
    background: #757575;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-btn:hover {
    background: #555;
}

/* Notes Styles */
.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    padding: 1rem 0;
}

.note-card {
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
    min-height: 150px;
    display: flex;
    flex-direction: column;
}

.note-card:hover {
    transform: translateY(-5px) rotate(1deg);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.note-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20px;
    width: 30px;
    height: 10px;
    background: rgba(0,0,0,0.1);
    border-radius: 0 0 5px 5px;
}

.note-title {
    font-size: 1.2rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px dashed rgba(0,0,0,0.1);
}

.note-content {
    flex: 1;
    font-size: 0.95rem;
    color: #555;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.note-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(0,0,0,0.1);
}

.note-date {
    font-size: 0.8rem;
    color: #888;
}

.note-actions {
    display: flex;
    gap: 0.5rem;
}

.note-actions button {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    border-radius: 6px;
}

/* Color Picker */
.color-picker {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.color-option {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    position: relative;
    transition: transform 0.2s, border-color 0.2s;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option input {
    display: none;
}

.color-option .checkmark {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2rem;
    color: #333;
    font-weight: bold;
}

.color-option input:checked + .checkmark {
    display: block;
}

.color-option input:checked ~ .checkmark,
.color-option.selected .checkmark {
    display: block;
}

.color-option input:checked {
    display: none;
}

.color-option:has(input:checked) {
    border-color: #333;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #333;
}

/* Empty state for notes */
.notes-empty {
    text-align: center;
    padding: 3rem;
    color: #999;
}

.notes-empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.notes-empty-text {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

/* Text warning color for notes */
.text-warning { color: #ffc107; }

/* ========== RESPONSIVE MOBILE ========== */

/* Tablet and below */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        padding: 0.75rem;
        gap: 0.75rem;
    }
    
    header h1 {
        font-size: 1.3rem;
    }
    
    nav {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
        width: 100%;
    }
    
    nav a {
        margin-left: 0;
        padding: 0.4rem 0.7rem;
        font-size: 0.85rem;
    }
    
    main {
        padding: 1rem;
    }
    
    .card {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .stat-label {
        font-size: 0.85rem;
    }
    
    /* Make tables scroll horizontally */
    .card:has(table) {
        overflow-x: auto;
        padding: 0.5rem;
    }
    
    table {
        min-width: 600px;
        font-size: 0.85rem;
    }
    
    th, td {
        padding: 0.6rem 0.5rem;
    }
    
    .action-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
        margin-right: 0.25rem;
    }
    
    /* Form adjustments */
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    button {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
    
    /* Modal full screen on mobile */
    .modal-content {
        width: 95%;
        max-width: none;
        max-height: 90vh;
        overflow-y: auto;
        padding: 1rem;
    }
    
    .modal-header h3 {
        font-size: 1.1rem;
    }
    
    /* Day cards */
    .daily-list {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .day-card {
        padding: 1rem;
    }
    
    .day-total {
        font-size: 1.2rem;
    }
    
    /* Notes grid */
    .notes-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .note-card {
        min-height: 120px;
        padding: 1rem;
    }
    
    .note-title {
        font-size: 1rem;
    }
    
    .note-content {
        font-size: 0.9rem;
    }
    
    .note-actions button {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
    }
    
    /* Color picker smaller */
    .color-option {
        width: 35px;
        height: 35px;
    }
    
    /* Detail view */
    .detail-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .detail-header h2 {
        font-size: 1.1rem;
    }
}

/* Small phones */
@media (max-width: 480px) {
    header h1 {
        font-size: 1.1rem;
    }
    
    nav a {
        padding: 0.35rem 0.5rem;
        font-size: 0.75rem;
    }
    
    main {
        padding: 0.75rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-value {
        font-size: 1.3rem;
    }
    
    .stat-label {
        font-size: 0.8rem;
    }
    
    table {
        font-size: 0.8rem;
    }
    
    th, td {
        padding: 0.5rem 0.4rem;
    }
    
    input, select {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 0.6rem;
    }
    
    .modal-content {
        padding: 0.75rem;
    }
    
    button {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .form-row button {
        width: auto;
        margin-bottom: 0;
    }
    
    .note-footer {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
    
    .note-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* Landscape phone adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .modal-content {
        max-height: 80vh;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}
