/* Reset e Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #e0e7ff;
    --success: #059669;
    --success-hover: #047857;
    --success-light: #d1fae5;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --danger-light: #fee2e2;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --white: #ffffff;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius: 8px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

html {
    font-size: 16px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    min-height: 100vh;
    color: var(--gray-800);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Navbar */
.navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    font-size: 20px;
    color: var(--gray-900);
    text-decoration: none;
    letter-spacing: -0.5px;
}

.logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: var(--white);
    border-radius: 12px;
    font-size: 20px;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 24px;
}

.nav-user {
    color: var(--gray-600);
    font-size: 14px;
    font-weight: 500;
}

.btn-logout {
    color: var(--danger);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.btn-logout:hover {
    background: var(--danger-light);
}

/* Auth Pages */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 80px);
    padding: 20px;
}

.auth-card {
    background: var(--white);
    padding: 48px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: var(--primary);
    color: var(--white);
    border-radius: 16px;
    font-size: 28px;
    font-weight: bold;
    margin-bottom: 20px;
    box-shadow: 0 8px 16px rgba(79, 70, 229, 0.25);
}

.auth-form .form-group {
    margin-bottom: 20px;
}

.auth-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--gray-700);
    font-size: 14px;
}

.auth-form input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    transition: all 0.2s;
    font-size: 15px;
    background: var(--gray-50);
}

.auth-form input:focus {
    background: var(--white);
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 4px var(--primary-light);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
    font-size: 14px;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 8px rgba(79, 70, 229, 0.3);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-800);
}

.btn-secondary:hover {
    background: var(--gray-200);
    color: var(--gray-900);
}

.btn-danger {
    background: var(--white);
    color: var(--danger);
    border: 1px solid var(--danger-light);
}

.btn-danger:hover {
    background: var(--danger);
    color: var(--white);
    border-color: var(--danger);
}

.btn-block {
    width: 100%;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 14px;
    color: var(--gray-600);
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

/* Dashboard */
.dashboard-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 40px 24px;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.dashboard-header h1 {
    color: var(--white);
    font-size: 32px;
    font-weight: 800;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn-add {
    background: var(--white);
    color: var(--primary);
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.btn-add:hover {
    background: var(--gray-50);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 48px;
}

.view-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.js-view-toggle.active {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.stat-card {
    background: var(--white);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: var(--primary-light);
    color: var(--primary);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--gray-900);
    line-height: 1.2;
}

.stat-label {
    font-size: 14px;
    color: var(--gray-500);
    font-weight: 500;
}

.stat-pending .stat-icon { background: var(--warning-light); color: var(--warning); }
.stat-paid .stat-icon { background: var(--success-light); color: var(--success); }
.stat-overdue .stat-icon { background: var(--danger-light); color: var(--danger); }

/* Boletos List */
.boletos-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.boleto-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    background: var(--white);
    border-radius: var(--radius-lg);
    border-left: 6px solid var(--primary);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.boleto-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.boleto-paid {
    border-left-color: var(--success);
    opacity: 0.8;
}

.boleto-paid:hover {
    opacity: 1;
}

.boleto-overdue {
    border-left-color: var(--danger);
    background: #fff5f5;
}

.boleto-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1;
    gap: 24px;
}

.boleto-info {
    flex: 1;
}

.boleto-descricao {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.boleto-details {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 14px;
    color: var(--gray-500);
}

.boleto-vencimento, .boleto-codigo {
    display: flex;
    align-items: center;
    gap: 6px;
}

.boleto-valor {
    text-align: right;
    min-width: 140px;
}

.valor {
    display: block;
    font-size: 20px;
    font-weight: 800;
    color: var(--gray-900);
}

.valor-danger { color: var(--danger); }

.valor-original {
    display: block;
    font-size: 13px;
    color: var(--gray-500);
    text-decoration: line-through;
    margin-top: 2px;
}

.status {
    font-size: 13px;
    font-weight: 600;
    margin-top: 4px;
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
}

.status-paid { color: var(--success); background: var(--success-light); }
.status-pending { color: var(--warning); background: var(--warning-light); }
.status-overdue { color: var(--danger); background: var(--danger-light); }

.boleto-actions {
    display: flex;
    gap: 8px;
    margin-left: 24px;
    z-index: 2; /* Ensure buttons are clickable above card click */
}

.grouped-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.group-block {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-100);
    overflow: hidden;
}

.group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    cursor: pointer;
}

.group-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-900);
}

.group-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}

.group-count {
    display: inline-block;
    min-width: 28px;
    text-align: center;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-light);
}

.group-caret {
    transition: transform 0.2s ease;
    color: var(--gray-500);
}

.group-list {
    padding: 16px;
    border-top: 1px solid var(--gray-100);
    display: none;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    background: var(--gray-50);
    color: var(--gray-300);
    border-radius: 50%;
    font-size: 40px;
    margin-bottom: 24px;
}

/* Forms */
.form-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 32px 24px;
}

.form-card {
    background: var(--white);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.form-header {
    margin-bottom: 32px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    margin-bottom: 20px;
    color: var(--gray-500);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.2s;
}

.back-link:hover { color: var(--primary); }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.form-group { margin-bottom: 24px; }

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--gray-700);
    font-size: 14px;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    transition: all 0.2s;
    font-size: 16px;
    background: var(--gray-50);
}

.form-group input:focus, .form-group select:focus {
    background: var(--white);
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 4px var(--primary-light);
}

.form-help {
    display: block;
    margin-top: 8px;
    font-size: 13px;
    color: var(--gray-500);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid var(--gray-100);
}

/* Toasts (Notifications) */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background: var(--white);
    padding: 16px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    animation: slideInRight 0.3s ease-out;
    border-left: 4px solid var(--gray-500);
}

.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }

.toast-icon { font-size: 20px; }
.toast-message { font-size: 14px; font-weight: 500; color: var(--gray-800); flex: 1; }
.toast-close { cursor: pointer; color: var(--gray-400); font-size: 18px; }

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(17, 24, 39, 0.6);
    backdrop-filter: blur(8px);
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--white);
    padding: 0;
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 500px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.4;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray-400);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--gray-600);
}

.modal-body {
    padding: 24px;
}

.detail-row {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.detail-label {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    font-weight: 600;
    margin-bottom: 8px;
}

.detail-value {
    font-size: 16px;
    color: var(--gray-900);
    font-weight: 500;
}

.detail-value.highlight {
    font-size: 24px;
    font-weight: 800;
    color: var(--primary);
}

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

.modal-actions {
    padding: 24px;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-100);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Debt Panel */
.debt-panel {
    margin-top: 12px;
    padding: 16px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}

.debt-header {
    font-size: 13px;
    font-weight: 700;
    color: var(--gray-700);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.debt-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.debt-item {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 12px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.debt-item .debt-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.debt-item .debt-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-900);
}

.debt-item.total {
    background: var(--primary-light);
    border-color: var(--primary);
}

.debt-item.total .debt-value {
    color: var(--primary);
    font-size: 18px;
}

/* File Management */
.boleto-files {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.file-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--gray-100);
    color: var(--gray-700);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
    border: 1px solid var(--gray-200);
}

.file-chip:hover {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.file-chip.pay {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

.btn-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.btn-link:hover {
    text-decoration: underline;
}
/* Custom File Input & Preview */
.custom-file-input-wrapper { margin-bottom: 12px; }

.custom-file-label {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--white);
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    color: var(--gray-600);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    justify-content: center;
}

.custom-file-label:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.image-preview-box {
    margin-top: 12px;
    padding: 12px;
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    display: none;
    box-shadow: var(--shadow-sm);
}

.image-preview-box img {
    max-width: 100%;
    max-height: 240px;
    border-radius: var(--radius);
    display: block;
    margin: 0 auto;
    object-fit: contain;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .nav-container { padding: 12px 16px; }
    .nav-user span { display: none; }

    .dashboard-container { padding: 24px 16px; }
    
    .dashboard-header {
        flex-direction: column;
        gap: 16px;
        align-items: stretch;
        text-align: center;
    }

    .stats-grid { grid-template-columns: 1fr; }

    .boleto-card {
        flex-direction: column;
        align-items: stretch;
        padding: 20px;
    }

    .boleto-main {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }

    .boleto-valor {
        text-align: left;
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: 16px;
        padding-top: 16px;
        border-top: 1px solid var(--gray-100);
    }
    
    .boleto-actions {
        margin-left: 0;
        margin-top: 20px;
        justify-content: stretch;
    }
    
    .boleto-actions .btn { flex: 1; }
    
    .form-container { padding: 24px 16px; }
    .form-card { padding: 24px; }
    .form-row { grid-template-columns: 1fr; }
    
    .form-actions {
        flex-direction: column-reverse;
    }
    
    .form-actions .btn { width: 100%; }
    
    .toast-container {
        left: 20px;
        right: 20px;
        top: 20px;
    }
    
    .toast { min-width: auto; }
}

/* Navbar Link */
.nav-link {
    color: var(--gray-700);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 999px;
    transition: all 0.2s;
}

.nav-link:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

/* Button Active Feedback */
.btn:active {
    transform: translateY(1px);
    filter: brightness(0.98);
}

/* Badges for inline alerts */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.badge-danger {
    background: var(--danger);
    color: var(--white);
}

.badge-warning {
    background: var(--warning);
    color: var(--white);
}

/* Toast close hover */
.toast-close:hover {
    color: var(--gray-600);
}
