/*
 * Global responsive UX/UI overrides for SAT web system.
 * Scope: pages rendered with common/sidebar + common/notis_footer.
 */

:root {
    --ux-bg: #f3f7fb;
    --ux-surface: #ffffff;
    --ux-surface-soft: #f8fbff;
    --ux-border: #d9e5f2;
    --ux-text: #0f172a;
    --ux-text-soft: #475569;
    --ux-muted: #64748b;
    --ux-radius: 14px;
    --ux-radius-sm: 10px;
    --ux-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
    --ux-shadow-sm: 0 4px 12px rgba(15, 23, 42, 0.07);
    --ux-tap: 44px;
    --ux-brand: #842637;
    --ux-brand-strong: #6b1e2c;
    --ux-brand-soft: #e7d2e5;
    --ux-sidebar-bg: #3e4095;
    --ux-sidebar-bg-soft: #4d4faa;
    --ux-sidebar-border: #2e3072;
    --ux-sidebar-text: #f3f7ff;
    --ux-sidebar-text-soft: #d3dffc;
    --ux-sidebar-hover: #595cb8;
    --ux-sidebar-accent: #f1c680;
    --ux-sidebar-accent-strong: #fff4d4;
    --ux-sidebar-pop: #f1c680;
    --ux-sidebar-width: clamp(252px, 18vw, 286px);
    --ux-sidebar-mini-width: 72px;
    --ux-sidebar-gutter: 12px;
}

html,
body {
    -webkit-text-size-adjust: 100%;
    text-rendering: optimizeLegibility;
}

body {
    background:
        radial-gradient(1100px 430px at -8% -10%, rgba(132, 38, 55, 0.16) 0%, rgba(132, 38, 55, 0) 62%),
        linear-gradient(180deg, #fbf4f6 0%, var(--ux-bg) 220px);
    color: var(--ux-text);
}

/* Smooth but respectful motion */
* {
    scroll-behavior: smooth;
}

@-webkit-keyframes ux-loader-spin {
    0% {
        -webkit-transform: rotate(0deg);
        transform: rotate(0deg);
    }
    100% {
        -webkit-transform: rotate(360deg);
        transform: rotate(360deg);
    }
}

@keyframes ux-loader-spin {
    0% {
        -webkit-transform: rotate(0deg);
        transform: rotate(0deg);
    }
    100% {
        -webkit-transform: rotate(360deg);
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }

    /* Mantener loaders activos para feedback de procesos largos */
    .spinner-border,
    .spinner-grow,
    .fa-spin,
    .fa-pulse,
    .swal2-loader,
    .ux-force-spin {
        -webkit-animation: ux-loader-spin 0.9s linear infinite !important;
        animation: ux-loader-spin 0.9s linear infinite !important;
    }
}

/* ===== Base Layout ===== */
#main-wrapper {
    min-height: 100vh;
}

.page-wrapper {
    min-height: calc(100vh - 64px);
    background: linear-gradient(180deg, rgba(132, 38, 55, 0.05) 0%, rgba(132, 38, 55, 0) 220px);
}

.container-fluid {
    max-width: 1680px;
    margin: 0 auto;
}

/* ===== Topbar / Sidebar ===== */
.topbar .top-navbar {
    background: linear-gradient(120deg, var(--ux-brand-strong) 0%, var(--ux-brand) 58%, #83223C 100%);
}

.topbar .navbar-header {
    min-height: 64px;
}

.topbar .top-navbar .navbar-header .navbar-brand {
    padding-left: 0.9rem;
    padding-right: 0.9rem;
}

.topbar .top-navbar.navbar-dark .navbar-nav .nav-link {
    color: #fdf0f3;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
}

.topbar .top-navbar.navbar-dark .navbar-nav .nav-link:hover,
.topbar .top-navbar.navbar-dark .navbar-nav .nav-link:focus {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

/* ================================================================
   SIDEBAR — Replaced by sat-sidebar.css
   ================================================================ */

/* ===== Surface System ===== */
.card {
    border: 1px solid var(--ux-border);
    border-radius: var(--ux-radius);
    box-shadow: var(--ux-shadow-sm);
    overflow: hidden;
}

.card .card-header {
    background: linear-gradient(140deg, #fff5f8 0%, #ffffff 65%, #f6eef1 100%);
    border-bottom: 1px solid var(--ux-border);
}

.card .card-title {
    color: var(--ux-text);
}

hr {
    border-color: #e4edf6;
}

/* ===== Form Controls ===== */
.form-control,
.custom-select,
.select2-selection,
.btn,
.input-group-text {
    border-radius: var(--ux-radius-sm);
}

.form-control,
.custom-select {
    border-color: #ccd9e8;
}

.form-control:focus,
.custom-select:focus {
    border-color: #9f3a4f;
    box-shadow: 0 0 0 0.18rem rgba(132, 38, 55, 0.16);
}

.btn {
    min-height: 38px;
}

.btn-group {
    flex-wrap: wrap;
    row-gap: 0.35rem;
}

/* ===== Tables ===== */
.table {
    margin-bottom: 0;
}

.table th,
.table td {
    vertical-align: middle;
}

.table-responsive {
    border-radius: var(--ux-radius-sm);
}

.table-responsive .table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--ux-surface-soft);
    border-bottom: 1px solid var(--ux-border);
}

.table-responsive .table tbody tr {
    transition: background-color 0.16s ease, transform 0.16s ease;
}

.table-responsive .table tbody tr:hover {
    background: #fdf3f6;
}

/* Helper class set by JS for stacked mobile table cards */
@media (max-width: 767.98px) {
    .table-responsive {
        border: 0;
        overflow: visible;
    }

    .ux-stack-on-mobile thead {
        display: none;
    }

    .ux-stack-on-mobile,
    .ux-stack-on-mobile tbody,
    .ux-stack-on-mobile tr,
    .ux-stack-on-mobile td {
        display: block;
        width: 100%;
    }

    .ux-stack-on-mobile tr {
        border: 1px solid var(--ux-border);
        border-radius: 12px;
        background: #fff;
        margin-bottom: 10px;
        box-shadow: var(--ux-shadow-sm);
        overflow: hidden;
    }

    .ux-stack-on-mobile td {
        border: 0 !important;
        border-bottom: 1px dashed #e6edf5 !important;
        padding: 8px 12px !important;
        text-align: left !important;
        white-space: normal;
        min-height: 36px;
    }

    .ux-stack-on-mobile td:last-child {
        border-bottom: 0 !important;
    }

    .ux-stack-on-mobile td::before {
        content: attr(data-label);
        display: block;
        font-size: 11px;
        line-height: 1.2;
        margin-bottom: 2px;
        color: var(--ux-muted);
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.03em;
    }
}

/* ===== Modal UX ===== */
.modal-content {
    border: 1px solid var(--ux-border);
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.2);
}

.modal-header,
.modal-footer {
    border-color: #e2eaf3;
}

@media (max-width: 767.98px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .modal-dialog.modal-dialog-centered {
        align-items: flex-end;
        min-height: calc(100% - 1rem);
    }

    .modal-content {
        border-radius: 12px;
    }

    .modal-body {
        max-height: 72vh;
        overflow-y: auto;
    }
}

/* ===== Footer ===== */
.footer,
.footer.page-wrapper {
    margin-left: 0 !important;
    width: 100%;
    min-height: 0 !important;
    height: auto !important;
    padding: 10px 18px !important;
    line-height: 1.35;
    display: block;
    border-top: 1px solid #deebf7;
    background: #f8fbff;
    color: #64748b;
}

/* ===== Mobile / Tablet pass ===== */
@media (max-width: 991.98px) {
    .container-fluid {
        padding-left: 12px;
        padding-right: 12px;
    }

    .page-wrapper {
        padding-bottom: 10px;
    }

    .card {
        border-radius: 12px;
    }

    .topbar .top-navbar .navbar-header .navbar-brand {
        max-width: 65%;
        padding-left: 0.6rem;
        padding-right: 0.6rem;
    }

    .topbar .navbar-header {
        min-height: 58px;
    }

    .user-menu {
        min-width: min(320px, calc(100vw - 20px));
    }

    .dropdown-menu-right {
        right: 0.4rem !important;
        left: auto !important;
    }

}

@media (max-width: 575.98px) {
    :root {
        --ux-tap: 46px;
    }

    .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }

    .card-body {
        padding: 0.85rem;
    }

    .btn,
    .form-control,
    .custom-select,
    .input-group-text,
    .navbar .nav-link {
        min-height: var(--ux-tap);
    }

    .btn {
        font-size: 0.92rem;
    }

    .topbar .navbar-brand .logo-text img {
        max-height: 36px;
        width: auto !important;
    }

    .etl-notif-menu,
    .user-menu {
        width: min(350px, calc(100vw - 14px));
        max-width: calc(100vw - 14px);
        border-radius: 12px;
    }

}

/* ===== Accessibility focus ring ===== */
:focus-visible {
    outline: 2px solid var(--ux-brand);
    outline-offset: 2px;
}
