/* ==========================================
   RESPONSIVE TYPOGRAPHY (REQ-03)
   Base: 14px mobile, 16px tablet+
   ========================================== */
html { font-size: 14px; }

@media (min-width: 481px) {
    html { font-size: 16px; }
}

/* ==========================================
   RESPONSIVE IMAGES (REQ-05)
   ========================================== */
img {
    max-width: 100%;
    height: auto;
}

/* Cards */
.card {
    text-align: center;
    padding: 1rem;
}
.card header {
    font-size: 0.875rem;
    opacity: 0.7;
    margin-bottom: 0.25rem;
    padding: 0;
    border: none;
}
.card-value {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
}
.card-success { border-left: 4px solid #2ecc71; }
.card-warning { border-left: 4px solid #f39c12; }
.card-danger { border-left: 4px solid #e74c3c; }
.card-value-currency { font-size: 1.5rem; }

/* Charts */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin: 1rem 0 2rem;
}
.chart-card {
    padding: 1rem;
    text-align: center;
}
.chart-card header {
    font-size: 0.9rem;
    opacity: 0.75;
    margin-bottom: 0.5rem;
    padding: 0;
    border: none;
}
.chart-svg {
    width: 100%;
    height: auto;
    max-height: 240px;
    display: block;
    margin: 0 auto;
}
.chart-donut { max-width: 220px; }
.chart-legend {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 1rem;
    font-size: 0.85rem;
}
.chart-legend .legend-swatch {
    display: inline-block;
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 2px;
    margin-right: 0.35rem;
    vertical-align: middle;
}

/* Progress */
.progress-section {
    margin: 1.5rem 0;
}
.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

/* Table rows */
.row-paid { opacity: 0.6; }
.row-overdue { border-left: 3px solid #e74c3c; }
.row-due-today { border-left: 3px solid #f39c12; background-color: rgba(243, 156, 18, 0.05); }
.row-due-soon { border-left: 3px solid #3498db; }

/* Badges */
.badge-paid {
    background-color: #2ecc71;
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}
.badge-overdue {
    background-color: #e74c3c;
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}
.badge-pending {
    background-color: #f39c12;
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

/* ==========================================
   TOUCH TARGETS (REQ-04) - min 44x44px on mobile/tablet
   ========================================== */
@media (max-width: 1024px) {
    button,
    a[role="button"],
    input[type="submit"],
    input[type="button"] {
        min-height: 44px;
    }
}

/* Buttons */
.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}
.btn-new {
    padding: 0.25rem 0.75rem;
    font-size: 0.85rem;
}
.btn-icon {
    padding: 0.25rem 0.5rem;
    font-size: 1rem;
    line-height: 1;
    width: 2.75rem;
    height: 2.75rem;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-sizing: border-box;
}

/* Page header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.page-header h2 {
    margin: 0;
}

/* Actions column */
.actions {
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.actions form {
    margin: 0;
    padding: 0;
    display: inline-flex;
}
.actions .btn-icon {
    width: 2.75rem;
    height: 2.75rem;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border: 1px solid;
    border-radius: 0.25rem;
    font-size: 1rem;
    line-height: 1;
    box-sizing: border-box;
}

/* ==========================================
   BREAKPOINTS (REQ-01):
   Mobile:  max-width: 480px
   Tablet:  481px – 1024px
   Desktop: 1025px+
   Responsive: table on desktop, cards on mobile/tablet
   ========================================== */
.cards-mobile { display: none; }
.table-desktop { display: block; }

@media (max-width: 1024px) {
    .table-desktop { display: none; }
    .cards-mobile { display: block; }
}

/* Mobile sort controls (≤1024px) */
.bill-sort-controls {
    margin-bottom: 0.75rem;
}
.bill-sort-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.bill-sort-row label {
    font-size: 0.85rem;
    margin: 0;
    flex: 0 0 auto;
}
.bill-sort-row select {
    flex: 1 1 auto;
    margin: 0;
    min-height: 44px;
}
#bill-sort-direction {
    flex: 0 0 auto;
    min-width: 44px;
    min-height: 44px;
    padding: 0 0.75rem;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Bill cards (mobile/tablet) */
.bill-card {
    padding: 1rem;
    margin-bottom: 0.75rem;
}
.bill-card.row-overdue { border-left: 3px solid #e74c3c; }
.bill-card.row-due-today { border-left: 3px solid #f39c12; background-color: rgba(243, 156, 18, 0.05); }
.bill-card.row-due-soon { border-left: 3px solid #3498db; }
.bill-card.row-paid { opacity: 0.6; }
.bill-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}
.bill-card-desc {
    font-size: 0.85rem;
    opacity: 0.7;
    margin: 0 0 0.5rem 0;
}
.bill-card-details {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}
.bill-card-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}
.bill-card-actions button,
.bill-card-actions a[role="button"] {
    text-align: center;
    margin: 0;
}

/* Mobile adjustments (≤480px) */
@media (max-width: 480px) {
    .page-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    .page-header a[role="button"] {
        text-align: center;
    }
}

/* Tablet adjustments (481px–1024px) */
@media (min-width: 481px) and (max-width: 1024px) {
    .page-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    .page-header a[role="button"] {
        text-align: center;
    }
}

/* ==========================================
   HAMBURGER NAVIGATION (REQ-06)
   Hidden hamburger on desktop; visible on mobile
   ========================================== */
.hamburger-btn {
    display: none;
}

/* nav-menu is transparent on desktop so <ul> elements flow normally */
.nav-menu {
    display: contents;
}

/* Mobile (≤480px): show hamburger, collapse nav */
@media (max-width: 480px) {
    nav.container-fluid {
        flex-wrap: wrap;
        position: relative;
    }
    .hamburger-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 44px;
        min-height: 44px;
        margin-left: auto;
        order: 2;
        font-size: 1.25rem;
    }
    .nav-menu {
        display: none;
        flex-direction: column;
        order: 3;
        width: 100%;
        padding: 0.5rem 0;
        border-top: 1px solid rgba(0, 0, 0, 0.1);
    }
    .nav-menu.open {
        display: flex;
    }
    .nav-menu ul {
        display: flex;
        flex-direction: column;
        width: 100%;
        padding: 0;
        margin: 0;
        gap: 0.25rem;
    }
    .nav-menu ul li {
        width: 100%;
    }
    .nav-menu ul li a,
    .nav-menu ul li a[role="button"],
    .nav-menu ul li button {
        width: 100%;
        display: block;
        text-align: left;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

/* Flash messages */
.flash-error {
    background-color: rgba(231, 76, 60, 0.1);
    border-left: 4px solid #e74c3c;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}
.flash-success {
    background-color: rgba(46, 204, 113, 0.1);
    border-left: 4px solid #2ecc71;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

/* Sortable table headers */
th[data-sort] {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
th[data-sort]:hover {
    opacity: 0.8;
}
.sort-icon {
    font-size: 0.75rem;
    opacity: 0.4;
    margin-left: 0.25rem;
}
th[data-sort-dir="asc"] .sort-icon,
th[data-sort-dir="desc"] .sort-icon {
    opacity: 1;
}

/* Footer */
footer {
    text-align: center;
    padding: 1rem 0;
    opacity: 0.5;
}
