/* ===== ROOT STYLES ===== */
* {
    -webkit-tap-highlight-color: transparent;
}

body { 
    padding-bottom: 40px;
    font-size: 16px;
}

/* ===== CARD STYLING ===== */
.card { 
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    margin-bottom: 1rem;
}

/* Dashboard card styling */
.card.border-left-primary { border-left: 4px solid #007bff; }
.card.border-left-success { border-left: 4px solid #28a745; }
.card.border-left-danger { border-left: 4px solid #dc3545; }
.card.border-left-warning { border-left: 4px solid #ffc107; }
.card.border-left-info { border-left: 4px solid #17a2b8; }
.card.border-left-secondary { border-left: 4px solid #6c757d; }

/* ===== TEXT STYLES ===== */
.font-weight-bold { font-weight: 700; }
.text-uppercase { text-transform: uppercase; }
.h3 { font-size: 1.75rem; font-weight: 600; }

/* ===== NAVIGATION ===== */
.navbar {
    padding: 0.5rem 0;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
    margin-right: 1rem;
}

.navbar-nav .nav-link {
    padding: 0.5rem 1rem !important;
    font-size: 0.95rem;
}

/* ===== TABLES - MOBILE RESPONSIVE ===== */
.table {
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.table th {
    background-color: #f8f9fa;
    color: #212529;
    font-weight: 600;
    white-space: nowrap;
    padding: 0.75rem;
}

.table td {
    padding: 0.75rem;
    vertical-align: middle;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Horizontal scroll indicator for mobile */
@media (max-width: 576px) {
    .table-responsive::after {
        content: "← Swipe to scroll →";
        display: block;
        text-align: center;
        font-size: 0.75rem;
        color: #999;
        margin-top: 0.5rem;
    }
    
    .table {
        font-size: 0.8rem;
        margin-bottom: 0.5rem;
    }
    
    .table th {
        padding: 0.5rem 0.25rem;
        font-size: 0.75rem;
    }
    
    .table td {
        padding: 0.5rem 0.25rem;
        font-size: 0.8rem;
    }
}

/* ===== BUTTONS ===== */
.btn {
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    text-decoration: none;
    display: inline-block;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.8rem;
}

.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

@media (max-width: 576px) {
    .btn {
        padding: 0.6rem 0.8rem;
        font-size: 0.9rem;
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .btn-sm {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
        width: auto;
        margin-bottom: 0.25rem;
    }
    
    .btn-group {
        flex-direction: column;
    }
}

/* ===== FORMS ===== */
.form-control,
.form-select {
    padding: 0.6rem 0.75rem;
    font-size: 1rem;
    border-radius: 4px;
    border: 1px solid #ddd;
    margin-bottom: 1rem;
}

.form-control:focus,
.form-select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

@media (max-width: 576px) {
    .form-control,
    .form-select {
        width: 100%;
        font-size: 16px;
        padding: 0.75rem;
    }
}

/* ===== LAYOUT RESPONSIVE ===== */
.container-fluid {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.container {
    padding-left: 1rem;
    padding-right: 1rem;
}

@media (max-width: 576px) {
    .container,
    .container-fluid {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    h1 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }
    
    h2 {
        font-size: 1.25rem;
        margin-bottom: 0.75rem;
    }
    
    h3 {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }
}

/* ===== CARDS ===== */
.card {
    margin-bottom: 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.card-header {
    background-color: #f8f9fa;
    padding: 1rem;
    border-bottom: 1px solid #ddd;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    background-color: #f8f9fa;
    padding: 1rem;
    border-top: 1px solid #ddd;
}

@media (max-width: 576px) {
    .card-body {
        padding: 0.75rem;
    }
}

/* ===== ROW/COLUMN SPACING ===== */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -0.5rem;
    margin-left: -0.5rem;
}

[class*='col-'] {
    flex-basis: 0;
    flex-grow: 1;
    max-width: 100%;
    padding-right: 0.5rem;
    padding-left: 0.5rem;
}

@media (max-width: 992px) {
    .col-lg-3,
    .col-lg-4,
    .col-lg-6,
    .col-lg-8 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

@media (max-width: 576px) {
    .col-md-2,
    .col-md-3,
    .col-md-4,
    .col-md-6,
    .col-md-8 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ===== ALERTS ===== */
.alert {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 4px;
    border: 1px solid transparent;
}

.alert-success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}

.alert-danger {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}

.alert-info {
    color: #0c5460;
    background-color: #d1ecf1;
    border-color: #bee5eb;
}

.alert-warning {
    color: #856404;
    background-color: #fff3cd;
    border-color: #ffeaa7;
}

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 12px;
    text-transform: uppercase;
}

.bg-success { background-color: #28a745 !important; color: white; }
.bg-danger { background-color: #dc3545 !important; color: white; }
.bg-warning { background-color: #ffc107 !important; color: #333; }
.bg-info { background-color: #17a2b8 !important; color: white; }
.bg-primary { background-color: #007bff !important; color: white; }

/* ===== MODALS/DIALOGS ===== */
.modal-content {
    border-radius: 8px;
    border: 1px solid #ddd;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #ddd;
    background-color: #f8f9fa;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #ddd;
}

@media (max-width: 576px) {
    .modal-dialog {
        margin: 0.5rem;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
}

/* ===== LINKS ===== */
a {
    color: #007bff;
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: #0056b3;
    text-decoration: underline;
}

/* ===== UTILITY CLASSES ===== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.pt-2 { padding-top: 1rem; }
.pb-2 { padding-bottom: 1rem; }
.px-2 { padding-left: 1rem; padding-right: 1rem; }

/* Use the available viewport width for forms and data-heavy report tables. */
.container {
    width: 100%;
    max-width: none;
    padding-left: clamp(0.75rem, 1.5vw, 1.5rem);
    padding-right: clamp(0.75rem, 1.5vw, 1.5rem);
}

.container-fluid {
    padding-left: clamp(0.75rem, 1.25vw, 1.25rem);
    padding-right: clamp(0.75rem, 1.25vw, 1.25rem);
}

.table th,
.table td {
    padding: 0.6rem 0.65rem;
}

.table-responsive {
    max-width: 100%;
    scrollbar-width: thin;
}

.bills-page .btn {
    border-radius: 0.55rem;
    font-weight: 600;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.bills-page .btn:focus-visible {
    outline: 3px solid rgba(13, 110, 253, 0.35);
    outline-offset: 2px;
}

.bills-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    min-width: 16rem;
}

.bills-actions .btn {
    margin: 0;
    white-space: nowrap;
}

/* ===== PRINT STYLES ===== */
.print-period {
    display: none;
}

@media print {
    @page {
        size: A4;
        margin: 12mm 14mm;
    }

    html,
    body {
        width: auto;
        background: #fff !important;
        color: #111 !important;
        font-size: 10pt;
        line-height: 1.35;
    }

    body {
        margin: 0;
        padding: 0;
    }

    .navbar,
    footer,
    .btn,
    .btn-group,
    form,
    script,
    .no-print,
    .print-hide {
        display: none !important;
    }

    .container,
    .container-fluid {
        width: auto !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .row {
        margin-left: -6px !important;
        margin-right: -6px !important;
    }

    .row > [class*="col-"] {
        padding-left: 6px !important;
        padding-right: 6px !important;
    }

    .card {
        border: 1px solid #b8c0c8 !important;
        border-radius: 2px !important;
        box-shadow: none !important;
        break-inside: avoid;
        page-break-inside: avoid;
        margin-bottom: 10px !important;
    }

    .card-header {
        background: #f1f3f5 !important;
        color: #111 !important;
        padding: 7px 9px !important;
        font-weight: 600;
    }

    .card-body {
        padding: 9px !important;
    }

    .table-responsive {
        overflow: visible !important;
    }

    .table {
        width: 100% !important;
        margin-bottom: 0 !important;
        font-size: 8.5pt;
        border-collapse: collapse !important;
    }

    .table th,
    .table td {
        padding: 4px 5px !important;
        border: 1px solid #cfd4da !important;
        vertical-align: middle;
    }

    .table thead {
        display: table-header-group;
    }

    .table tfoot {
        display: table-row-group;
    }

    .table tr {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    h1,
    h2,
    h3,
    h4,
    h5,
    h6 {
        color: #111 !important;
        page-break-after: avoid;
    }

    .text-muted {
        color: #444 !important;
    }

    .print-period {
        display: block !important;
        margin: 4px 0 0;
        color: #111 !important;
        font-size: 9pt;
        font-weight: 600;
    }

    .badge {
        border: 1px solid #555 !important;
        color: #111 !important;
        background: transparent !important;
    }

    canvas {
        max-width: 100% !important;
    }
}
