/* Componentes UI — substituto desacoplado do AdminLTE/Bootstrap */

/* ── Grid ── */

.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -0.625rem;
}

[class*="col-"] {
    padding: 0 0.625rem;
    width: 100%;
}

.col-5 { width: 41.666%; }
.col-7 { width: 58.333%; }
.col-12 { width: 100%; }

@media (min-width: 768px) {
    .col-md-2 { width: 16.666%; }
    .col-md-3 { width: 25%; }
    .col-md-4 { width: 33.333%; }
    .col-md-6 { width: 50%; }
}

@media (max-width: 767px) {
    .col-12.col-md-3,
    .col-12.col-md-2,
    .col-12.col-md-4,
    .col-12.col-md-6 {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -0.625rem 1rem;
}

.form-row > [class*="col-"] {
    padding: 0 0.625rem;
    margin-bottom: 0.75rem;
}

/* ── Panel ── */

.panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
    overflow: hidden;
}

.panel__header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
}

.panel__title {
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--color-text);
    margin: 0;
}

.panel__body {
    padding: 1.25rem;
    background: var(--color-surface);
}

.panel__toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

/* ── Card (compat. financial) ── */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
}

.card-title {
    font-size: 1.0625rem;
    font-weight: 700;
    margin: 0;
    color: var(--color-text);
}

.card-tools {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-body {
    padding: 1.25rem;
    background: var(--color-surface);
}

.card-footer {
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface-raised);
}

/* ── Forms ── */

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
    color: var(--color-text);
}

.form-control {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-family: var(--font);
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: 8px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--purple-400);
    box-shadow: 0 0 0 3px rgba(111, 66, 193, 0.15);
}

.form-control:disabled {
    background: var(--color-surface-raised);
    opacity: 0.8;
}

.form-control.is-invalid {
    border-color: #e53e3e;
}

.invalid-feedback {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.8125rem;
    color: #e53e3e;
}

.form-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.form-text {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

/* Switch */

.form-switch {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-bottom: 0.75rem;
}

.form-switch input[type="checkbox"] {
    width: 2.5rem;
    height: 1.375rem;
    appearance: none;
    background: var(--color-bg-subtle);
    border-radius: 999px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.form-switch input[type="checkbox"]::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 1.125rem;
    height: 1.125rem;
    background: var(--color-surface);
    border-radius: 50%;
    transition: transform 0.2s;
}

.form-switch input[type="checkbox"]:checked {
    background: var(--color-primary-fill);
}

.form-switch input[type="checkbox"]:checked::before {
    transform: translateX(1.125rem);
}

.form-switch label {
    font-size: 0.875rem;
    cursor: pointer;
}

.custom-control.custom-switch {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-bottom: 0.75rem;
}

.custom-control-input {
    width: 2.5rem;
    height: 1.375rem;
    appearance: none;
    background: var(--color-bg-subtle);
    border-radius: 999px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.custom-control-input::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 1.125rem;
    height: 1.125rem;
    background: var(--color-surface);
    border-radius: 50%;
    transition: transform 0.2s;
}

.custom-control-input:checked {
    background: var(--color-primary-fill);
}

.custom-control-input:checked::before {
    transform: translateX(1.125rem);
}

.custom-control-label {
    font-size: 0.875rem;
    cursor: pointer;
}

/* ── Buttons ── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
    text-align: center;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn:disabled,
.btn.disabled {
    opacity: 0.55;
    pointer-events: none;
}

.btn-sm { padding: 0.3rem 0.625rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.75rem 1.25rem; font-size: 1rem; }
.btn-block { display: flex; width: 100%; }

.btn-primary { background: var(--color-primary-fill); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); color: #fff; }

.btn-success { background: #38a169; color: #fff; }
.btn-success:hover { background: #2f855a; color: #fff; }

.btn-danger { background: #e53e3e; color: #fff; }
.btn-danger:hover { background: #c53030; color: #fff; }

.btn-warning { background: #d69e2e; color: #fff; }
.btn-warning:hover { background: #b7791f; color: #fff; }

.btn-info { background: #3182ce; color: #fff; }
.btn-info:hover { background: #2b6cb0; color: #fff; }

.btn-secondary,
.btn-default { background: #64748b; color: #fff; }
.btn-secondary:hover,
.btn-default:hover { background: #475569; color: #fff; }

.btn-outline-primary { background: transparent; border-color: var(--color-primary); color: var(--color-primary); }
.btn-outline-primary:hover { background: var(--purple-50); }

.btn-outline-secondary { background: transparent; border-color: var(--color-border); color: var(--color-text); }
.btn-outline-secondary:hover { background: var(--color-surface-raised); }

/* ── Tables ── */

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-surface);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table th,
.table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

.table thead th {
    background: var(--color-bg-subtle);
    font-weight: 700;
    color: var(--color-text);
    white-space: nowrap;
    border-bottom: 1px solid var(--color-border);
}

.table-hover tbody tr:hover {
    background: var(--color-hover);
}

.table-striped tbody tr:nth-child(even) {
    background: var(--color-surface-raised);
}

.table tbody tr {
    border-bottom: 1px solid var(--color-border);
}

.text-nowrap { white-space: nowrap; }

/* ── Badges ── */

.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 6px;
    line-height: 1;
}

.badge-success, .bg-success { background: #c6f6d5; color: #1a4731; border: 1px solid #276749; font-weight: 700; }
.badge-danger, .bg-danger { background: #fed7d7; color: #9b1c1c; border: 1px solid #c53030; font-weight: 700; }
.badge-warning, .bg-warning { background: #fefcbf; color: #744210; border: 1px solid #975a16; font-weight: 700; }
.badge-info, .bg-info { background: #bee3f8; color: #1a365d; border: 1px solid #2c5282; font-weight: 700; }
.badge-secondary, .bg-secondary { background: #e2e8f0; color: #1e293b; border: 1px solid #64748b; font-weight: 700; }
.badge-primary, .bg-primary { background: var(--purple-100); color: var(--purple-900); border: 1px solid var(--purple-700); font-weight: 700; }
.bg-light { background: var(--color-surface-raised); color: var(--color-text); border: 1px solid var(--color-border); }

/* ── Alerts ── */

.alert-warning {
    background: #fffbeb;
    border: 2px solid #b45309;
    color: #78350f;
    font-weight: 500;
}

/* ── Modal ── */

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    overflow: auto;
}

.modal.show {
    display: block;
}

.modal-open {
    overflow: hidden;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 1999;
}

.modal-dialog {
    position: relative;
    margin: 2rem auto;
    max-width: 500px;
    padding: 0 1rem;
    z-index: 2001;
}

.modal-dialog.modal-lg { max-width: 800px; }

.modal-content {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.modal-body { padding: 1.25rem; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--color-border);
}

.close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 0;
}

.close:hover { color: var(--color-text); }

/* ── Nav tabs ── */

.nav-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 1rem;
    list-style: none;
    padding: 0;
}

.nav-tabs .nav-link {
    display: block;
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: 8px 8px 0 0;
    color: var(--color-text-muted);
    cursor: pointer;
    text-decoration: none;
    font-size: 0.875rem;
}

.nav-tabs .nav-link.active {
    background: var(--color-primary-fill);
    color: #fff;
    border-color: var(--color-primary);
}

.nav-tabs .nav-link:hover:not(.active) {
    color: var(--color-primary);
}

.tab-content { margin-top: 1rem; }

/* ── Pagination ── */

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    list-style: none;
    padding: 0;
    margin: 0;
}

.page-item .page-link {
    display: block;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-primary);
    text-decoration: none;
    font-size: 0.875rem;
}

.page-item.active .page-link {
    background: var(--color-primary-fill);
    border-color: var(--color-primary);
    color: #fff;
}

.page-item.disabled .page-link {
    color: var(--color-text-muted);
    pointer-events: none;
}

/* ── Utilities ── */

.d-inline { display: inline; }
.d-flex { display: flex; }
.d-grid { display: grid; }
.d-inline-block { display: inline-block; }

.align-items-center { align-items: center; }
.align-items-end { align-items: flex-end; }
.justify-content-center { justify-content: center; }
.justify-content-between { justify-content: space-between; }

.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }

.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-muted); }
.text-danger { color: #e53e3e; }
.text-success { color: #38a169; }

.fw-bold { font-weight: 700; }
.fs-3 { font-size: 1.5rem; }
.fs-5 { font-size: 1.125rem; }

.border { border: 1px solid var(--color-border); }
.rounded { border-radius: var(--radius); }
.bg-light { background: var(--color-surface-raised); }

.w-100 { width: 100%; }

.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.my-0 { margin-top: 0; margin-bottom: 0; }
.my-2 { margin-top: 0.5rem; margin-bottom: 0.5rem; }
.ml-2 { margin-left: 0.5rem; }
.mr-2 { margin-right: 0.5rem; }
.ms-1 { margin-left: 0.25rem; }

.p-3 { padding: 0.75rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }

.panel + .panel,
.mt-3 { margin-top: 0.75rem; }

.page-header__actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: -2.5rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
    .page-header__actions {
        margin-top: 0;
        margin-bottom: 1rem;
        justify-content: flex-start;
    }
}
