* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 3px;
    overflow-x: hidden;
    margin: 0;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    overflow-x: hidden;
}

header {
    background: white;
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 5px;
    text-align: center;
}

header h1 {
    color: #667eea;
    font-size: 1.2em;
    margin-bottom: 8px;
}

/* User Menu Styles */
.user-menu-container {
    position: relative;
    display: inline-block;
}

.user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.6);
    width: 40px;
    height: 40px;
}

.user-avatar:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.8);
}

.avatar-icon {
    font-size: 1.2em;
    background: white;
    color: #667eea;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.username-text {
    display: none;
}

.dropdown-arrow {
    color: white;
    font-size: 0.7em;
    transition: transform 0.3s ease;
}

.user-menu-container:hover .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
    overflow: hidden;
}

.user-menu-container:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #333;
    text-decoration: none;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: #f8f9fa;
    padding-left: 20px;
}

.dropdown-item .item-icon {
    font-size: 1.2em;
}

.logout-item {
    color: #dc3545;
}

.logout-item:hover {
    background: #fff5f5;
}

.week-navigation {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    flex-wrap: nowrap;
    width: 100%;
}

.nav-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 5px 8px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.7em;
    transition: all 0.3s;
    flex-shrink: 0;
}

.nav-btn.week-arrow {
    background: transparent;
    color: #667eea;
    font-size: 1.1em;
    padding: 6px 10px;
    border-radius: 8px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.nav-btn.week-arrow:hover {
    background: #f8f9fa;
    color: #5568d3;
    transform: scale(1.05);
    border-color: #667eea;
    box-shadow: none;
}

.week-range {
    font-weight: 600;
    font-size: 0.85em;
    color: #333;
    text-align: center;
    white-space: nowrap;
    flex-shrink: 1;
    min-width: 0;
}

.nav-btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.check-overdue-btn.has-overdue {
    background: #dc3545 !important;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 10px rgba(220, 53, 69, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(220, 53, 69, 0.8);
    }
}

.days-container {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 2px;
    width: 100%;
}

.day-card {
    background: white;
    border-radius: 5px;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s;
    min-width: 0;
    overflow: hidden;
}
.day-card.past-day {
    background: LightGray;
}
.day-card:hover {
    transform: translateY(-5px);
}

/* Border color classes */
.day-card.border-red .day-header {
    border-left-color: #dc3545;
}
.day-card.border-green .day-header {
    border-left-color: #28a745;
}
.day-card.border-white .day-header {
    border-left-color: #ffffff;
}

.day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    padding: 8px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    user-select: none;
    position: relative;
    gap: 8px;
    border-left: 4px solid #ffffff;
}

.day-header:hover {
    background-color: #f8f9fa;
}

.day-info {
    flex: 0 0 auto;
    min-width: 80px;
}

.day-name {
    font-size: 0.85em;
    font-weight: bold;
    color: #667eea;
}

.day-date {
    color: #666;
    font-size: 0.65em;
}

.progress-section {
    flex: 1;
    margin: 0 8px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.progress-text {
    display: none;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: #f0f0f0;
    border-radius: 5px;
    overflow: hidden;
}

.progress-bar-payments {
    height: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #28a745, #155724);
    transition: width 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.5em;
    font-weight: bold;
}

.progress-fill-payments {
    background: linear-gradient(90deg, #722F37, #A4133C);
}

.collapse-indicator {
    font-size: 0.8em;
    color: #667eea;
    transition: transform 0.3s ease;
    padding: 4px 8px;
    flex: 0 0 auto;
}

.day-card.collapsed .collapse-indicator {
    transform: rotate(-90deg);
}

.day-content {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    max-height: 5000px;
    opacity: 1;
}

.day-card.collapsed .day-content {
    max-height: 0;
    opacity: 0;
    margin: 0;
    padding: 0;
}

.section-title {
    font-size: 0.75em;
    font-weight: bold;
    color: #333;
    margin: 5px 0 4px 0;
    display: flex;
    align-items: center;
    gap: 3px;
}

.tasks-list, .payments-list {
    min-height: 30px;
}

.item {
    background: #f8f9fa;
    padding: 4px;
    margin-bottom: 3px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
}

.item:hover {
    background: #e9ecef;
}

.item.completed .item-text {
    text-decoration: line-through;
    color: #999;
}

.item.completed .payment-info {
    text-decoration: line-through;
    color: #999;
}

.item.completed .payment-description,
.item.completed .payment-amount {
    color: #999;
}

.item-text {
    flex: 1;
    margin-right: 4px;
    word-break: break-word;
    font-size: 0.7em;
    overflow: hidden;
}

.payment-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    margin-right: 4px;
}

.payment-description {
    font-size: 0.7em;
}

.payment-amount {
    font-size: 0.75em;
    font-weight: normal;
    color: #dc3545;
}

.payment-total {
    background: #e8f5e9;
    padding: 6px 8px;
    margin-top: 5px;
    border-radius: 4px;
    text-align: right;
    font-size: 0.8em;
    border: 1px solid #c8e6c9;
}

.payment-total .total-label {
    color: #333;
    font-weight: normal;
}

.payment-total .total-amount {
    font-weight: bold;
}

.payment-total .total-amount.red {
    color: #dc3545;
}

.payment-total .total-amount.green {
    color: #28a745;
}

.payment-total .total-currency {
    font-weight: normal;
}

.payment-total .total-currency.red {
    color: #dc3545;
}

.payment-total .total-currency.green {
    color: #28a745;
}

.item-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.action-btn {
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.75em;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-complete {
    background: #28a745;
    color: white;
}

.btn-complete:hover {
    background: #218838;
    transform: scale(1.1);
}

.btn-move {
    background: #ffc107;
    color: white;
}

.btn-move:hover {
    background: #e0a800;
    transform: scale(1.1);
}

.btn-delete {
    background: #dc3545;
    color: white;
}

.btn-delete:hover {
    background: #c82333;
    transform: scale(1.1);
}

.add-section {
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.add-input-group {
    display: flex;
    gap: 2px;
}

.add-input {
    flex: 1;
    padding: 4px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-size: 0.7em;
    transition: border 0.3s;
    min-width: 0;
}

.add-input:focus {
    outline: none;
    border-color: #667eea;
}

.add-btn {
    padding: 4px 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.7em;
    transition: all 0.3s;
    white-space: nowrap;
    flex-shrink: 0;
}

.add-task-btn {
    background: #667eea;
    color: white;
}

.add-task-btn:hover {
    background: #5568d3;
}

.add-payment-btn {
    background: #28a745;
    color: white;
}

.add-payment-btn:hover {
    background: #218838;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    animation: fadeIn 0.3s;
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.5em;
}

.modal-content p {
    color: #666;
    margin-bottom: 20px;
    font-size: 1.1em;
}

.modal-content label {
    display: block;
    margin-bottom: 10px;
    color: #333;
    font-weight: bold;
}

.modal-content input[type="date"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    margin-bottom: 20px;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
}

.modal-buttons button {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    transition: all 0.3s;
}

.btn-confirm {
    background: #667eea;
    color: white;
}

.btn-confirm:hover {
    background: #5568d3;
}

.btn-cancel {
    background: #6c757d;
    color: white;
}

.btn-cancel:hover {
    background: #5a6268;
}

#deleteModal .btn-delete {
    width: auto;
    height: auto;
    padding: 12px 30px;
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8em;
    }

    .days-container {
        grid-template-columns: 1fr;
    }

    .add-input-group {
        flex-direction: column;
    }

    .modal-buttons {
        flex-direction: column;
    }

    .modal-buttons button {
        width: 100%;
    }

    /* Mobile: Make collapse indicator more visible */
    .collapse-indicator {
        font-size: 1.2em;
        padding: 8px 12px;
    }

    .day-header {
        padding: 6px;
        border-radius: 8px;
        transition: background-color 0.2s ease;
    }

    .day-header:active {
        background-color: #e9ecef;
    }
    
    .progress-section {
        gap: 2px;
    }
    
    .progress-bar {
        height: 14px;
    }
    
    .progress-bar-payments {
        height: 12px;
    }
    
    .progress-fill {
        font-size: 0.6em;
    }
}

/* Empty state */
.empty-state {
    text-align: center;
    color: #999;
    padding: 10px;
    font-style: italic;
    font-size: 0.7em;
}

/* Alert Modal */
.alert-modal {
    max-width: 600px;
}

.alert-content {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
}

.alert-day {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 5px;
}

.alert-day-title {
    font-weight: bold;
    color: #856404;
    margin-bottom: 8px;
    font-size: 1.1em;
}

.alert-item {
    background: white;
    padding: 8px;
    margin: 5px 0;
    border-radius: 4px;
    border-left: 3px solid #dc3545;
    font-size: 0.95em;
    color: #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.alert-item.payment {
    border-left-color: #28a745;
}

.alert-item-text {
    flex: 1;
}

.alert-item-actions {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

.alert-item-actions .action-btn {
    width: 28px;
    height: 28px;
    font-size: 1em;
}

.alert-item-actions .btn-complete {
    background: #28a745;
}

.alert-item-actions .btn-complete:hover {
    background: #218838;
}

.alert-item-actions .btn-move {
    background: #ffc107;
}

.alert-item-actions .btn-move:hover {
    background: #e0a800;
}

.alert-item-actions .btn-delete {
    background: #dc3545;
}

.alert-item-actions .btn-delete:hover {
    background: #c82333;
}

/* Overdue styles for database version */
.overdue-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.overdue-day {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 12px;
    border-radius: 5px;
}

.overdue-day-header {
    font-weight: bold;
    color: #856404;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.overdue-section-title {
    font-weight: bold;
    color: #856404;
    margin: 8px 0 5px 0;
    font-size: 0.95em;
}

.overdue-item {
    background: white;
    padding: 8px 10px;
    margin: 5px 0;
    border-radius: 4px;
    border-left: 3px solid #dc3545;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.overdue-item-text {
    flex: 1;
    font-size: 0.95em;
    color: #333;
}

.overdue-item-actions {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

.overdue-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-complete-overdue {
    background: #28a745;
    color: white;
}

.btn-complete-overdue:hover {
    background: #218838;
    transform: scale(1.1);
}

.btn-move-overdue {
    background: #ffc107;
    color: #333;
}

.btn-move-overdue:hover {
    background: #e0a800;
    transform: scale(1.1);
}

.btn-delete-overdue {
    background: #dc3545;
    color: white;
}

.btn-delete-overdue:hover {
    background: #c82333;
    transform: scale(1.1);
}
