/* =========================================================
   ErgoFlow CRM - App UI Polish
   Phase 13: UI consistency / layout / responsive cleanup
   ========================================================= */

/* ---------- Base ---------- */

body {
    font-size: 0.95rem;
    background-color: #f5f7fb;
    color: #212529;
}

a {
    text-underline-offset: 2px;
}

.app-wrapper {
    min-height: 100vh;
}

.content-area {
    padding: 1.25rem;
}

/* ---------- Topbar ---------- */

.topbar {
    background: #ffffff;
    border-bottom: 1px solid #dee2e6;
    min-height: 64px;
}

.brand-box {
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.01em;
}

.topbar .btn {
    white-space: nowrap;
}

/* ---------- Sidebar ---------- */

.sidebar {
    min-height: 100vh;
    background: #212529;
}

.sidebar .nav-link {
    color: #ced4da;
    border-radius: 0.375rem;
    padding: 0.55rem 0.75rem;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar .nav-link.active,
.sidebar .nav-link:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar .nav-link.text-warning:hover {
    color: #ffc107 !important;
    background: rgba(255, 193, 7, 0.12);
}

.sidebar-section-title {
    letter-spacing: 0.04em;
}

/* ---------- Page headers ---------- */

/*
   Most existing pages use:
   <main class="... content-area">
       <div class="d-flex justify-content-between align-items-center mb-4">
   This improves wrapping without requiring every page to be rewritten.
*/

.content-area > .d-flex.justify-content-between {
    gap: 0.75rem;
    flex-wrap: wrap;
}

.content-area h1,
.content-area .h3 {
    letter-spacing: -0.015em;
}

.content-area h1.h3,
.content-area .h3 {
    font-weight: 700;
}

/* ---------- Cards / sections ---------- */

.card {
    border-radius: 0.65rem;
}

.card.shadow-sm.border-0 {
    box-shadow: 0 0.25rem 1rem rgba(15, 23, 42, 0.06) !important;
}

.card-title {
    font-weight: 600;
}

.card-header {
    border-top-left-radius: 0.65rem !important;
    border-top-right-radius: 0.65rem !important;
}

.card-body > :last-child {
    margin-bottom: 0;
}

/* ---------- Forms ---------- */

.form-label {
    font-weight: 600;
    color: #343a40;
    margin-bottom: 0.35rem;
}

.form-control,
.form-select {
    border-radius: 0.45rem;
}

.form-control:focus,
.form-select:focus {
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.12);
}

textarea.form-control {
    min-height: 110px;
}

/* ---------- Buttons ---------- */

.btn {
    border-radius: 0.45rem;
    font-weight: 500;
}

.btn-sm {
    border-radius: 0.4rem;
}

.btn-primary {
    box-shadow: 0 0.15rem 0.4rem rgba(13, 110, 253, 0.12);
}

.btn-outline-danger {
    background-color: #ffffff;
}

.btn-outline-danger:hover {
    color: #ffffff;
}

/*
   Existing list pages use:
   <div class="d-flex flex-wrap gap-2"> inside the Actions column.
   This keeps list actions consistent and prevents awkward wrapping.
*/

td .d-flex.flex-wrap.gap-2,
td .d-inline-flex.flex-wrap.gap-1,
.card-footer .d-flex.flex-wrap,
.modal-footer,
.form-actions,
.page-actions {
    align-items: center;
}

td form {
    margin-bottom: 0;
}

td .btn,
td form .btn {
    white-space: nowrap;
}

/* ---------- Tables ---------- */

.table {
    margin-bottom: 0;
}

.table thead th {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: #495057;
    background-color: #f8f9fa;
    border-bottom-width: 1px;
    white-space: nowrap;
}

.table tbody td {
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.035);
}

.table-responsive {
    border-radius: 0.55rem;
}

/* ---------- Badges / status ---------- */

.badge {
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* ---------- Alerts ---------- */

.alert {
    border-radius: 0.6rem;
}

/* ---------- Attachment previews from Phase 12 ---------- */

.card-img-top {
    background-color: #f8f9fa;
}

.modal-body img.img-fluid {
    background-color: #ffffff;
}

/* ---------- Dashboard / statistic cards ---------- */

.card .h4,
.card .h5,
.card .display-6 {
    font-weight: 700;
}

/* ---------- Search/filter cards ---------- */

.card form.row.g-3 {
    align-items: end;
}

/* ---------- Mobile / responsive cleanup ---------- */

@media (max-width: 991.98px) {
    .topbar .container-fluid {
        gap: 0.75rem;
        flex-wrap: wrap;
    }

    .topbar .d-flex {
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .content-area {
        padding: 1rem;
    }

    .sidebar {
        min-height: auto;
    }
}

@media (max-width: 767.98px) {
    body {
        font-size: 0.92rem;
    }

    .content-area > .d-flex.justify-content-between {
        align-items: stretch !important;
    }

    .content-area > .d-flex.justify-content-between > * {
        width: 100%;
    }

    .content-area > .d-flex.justify-content-between .btn,
    .content-area > .d-flex.justify-content-between .d-flex .btn {
        width: 100%;
    }

    .content-area > .d-flex.justify-content-between .d-flex {
        width: 100%;
        flex-wrap: wrap;
    }

    .card-body {
        padding: 1rem;
    }

    td .d-flex.flex-wrap.gap-2,
    td .d-inline-flex.flex-wrap.gap-1 {
        gap: 0.35rem !important;
    }

    td .btn,
    td form .btn {
        width: 100%;
    }

    td form {
        width: 100%;
    }

    .table thead th {
        font-size: 0.78rem;
    }

    .btn {
        white-space: normal;
    }
}

@media (max-width: 575.98px) {
    .topbar {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    .brand-box {
        font-size: 1rem;
    }

    .sidebar {
        padding: 1rem !important;
    }

    .content-area {
        padding: 0.85rem;
    }
}