/* ================================================================
   AGENTTOOLS — APP LAYOUT v2.0
   Paleta Ocean Blue oficial · Container responsivo · Componentes
   Carregado APÓS todos os outros CSS pelo _Layout.cshtml.
   ================================================================ */

/* ── 0. PALETA OFICIAL ─────────────────────────────────────────── */
:root {
    --at-ocean:    #002B45;
    --at-primary:  #1E4E8C;
    --at-sky:      #5BA8FF;
    --at-sky-soft: #E6F1FF;
    --at-gray:     #68728B;
    --at-white:    #FFFFFF;

    --at-border:     rgba(30, 78, 140, 0.14);
    --at-shadow:     0 12px 32px rgba(0, 43, 69, 0.08);
    --at-shadow-sm:  0 4px 16px rgba(0, 43, 69, 0.06);
    --at-radius:     16px;
    --at-radius-sm:  10px;
    --at-radius-lg:  22px;

    /* legado -- exec-* aponta para a paleta oficial */
    --exec-primary:  #1E4E8C;
    --exec-light:    #F0F7FF;
    --exec-border:   rgba(30, 78, 140, 0.14);
}

/* ── 1. BASE ───────────────────────────────────────────────────── */
html {
    background: #E6F1FF !important;
}

html body.app-body,
body.app-body {
    background: #E6F1FF !important;
    color: #002B45 !important;
    min-height: 100vh;
}

/* ── 2. SHELL + MAIN ───────────────────────────────────────────── */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: #E6F1FF;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #E6F1FF !important;
    color: #002B45;
}

/* ── 3. CONTAINER RESPONSIVO ───────────────────────────────────── */
.at-app-container {
    width: min(100% - 48px, 1440px);
    margin: 0 auto;
    padding: 32px 0 48px;
    flex: 1;
    animation: fadeInUp 0.22s ease-out;
}

.at-app-container--full-bleed {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    animation: none;
}

@media (max-width: 768px) {
    .at-app-container {
        width: min(100% - 24px, 1440px);
        padding: 20px 0 32px;
    }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0);   }
}

/* ── 4. NAVBAR ─────────────────────────────────────────────────── */
body.app-body .app-navbar,
body.app-body .navbar {
    background: linear-gradient(90deg, #002B45 0%, #1E4E8C 100%) !important;
    box-shadow: 0 4px 20px rgba(0, 43, 69, 0.20) !important;
    min-height: 64px;
}

body.app-body .navbar .nav-link {
    color: rgba(255, 255, 255, 0.86) !important;
    font-weight: 500;
    padding: 0.45rem 0.85rem !important;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
}

body.app-body .navbar .nav-link:hover {
    color: #fff !important;
    background: rgba(91, 168, 255, 0.14) !important;
}

body.app-body .navbar .nav-link.active {
    color: #5BA8FF !important;
    background: rgba(91, 168, 255, 0.18) !important;
}

body.app-body .navbar-brand,
body.app-body .brand-wordmark {
    color: #fff !important;
}

body.app-body .navbar .dropdown-toggle {
    color: rgba(255, 255, 255, 0.86) !important;
}

body.app-body .navbar-toggler {
    border-color: rgba(255, 255, 255, 0.25) !important;
}

body.app-body .navbar-toggler-icon {
    filter: invert(1) !important;
}

/* ── 5. FOOTER ─────────────────────────────────────────────────── */
body.app-body .app-footer,
body.app-body .footer {
    position: static !important;
    flex-shrink: 0;
    background: #E6F1FF !important;
    border-top: 1px solid rgba(30, 78, 140, 0.12) !important;
    color: #68728B !important;
    width: auto !important;
    line-height: normal !important;
    padding: 24px 0 !important;
}

/* ── 6. TIPOGRAFIA ─────────────────────────────────────────────── */
body.app-body h1, body.app-body h2, body.app-body h3,
body.app-body h4, body.app-body h5, body.app-body h6,
body.app-body .page-title, body.app-body .section-title,
body.app-body .at-page-title {
    color: #002B45 !important;
}

body.app-body .text-muted,
body.app-body .page-subtitle, body.app-body .section-subtitle,
body.app-body .at-page-subtitle, body.app-body .exec-subtitle {
    color: #68728B !important;
}

body.app-body p {
    color: inherit;
}

/* ── 7. CARDS ──────────────────────────────────────────────────── */
body.app-body .card,
body.app-body .app-card,
body.app-body .dashboard-card,
body.app-body .metric-card,
body.app-body .content-card,
body.app-body .section-card,
body.app-body .exec-stat-card {
    background: #FFFFFF !important;
    color: #002B45 !important;
    border: 1px solid rgba(30, 78, 140, 0.14) !important;
    border-radius: 16px !important;
    box-shadow: 0 4px 16px rgba(0, 43, 69, 0.07) !important;
}

body.app-body .card-header {
    background: #FFFFFF !important;
    border-bottom: 1px solid rgba(30, 78, 140, 0.10) !important;
    color: #002B45 !important;
    font-weight: 600;
}

body.app-body .card-footer {
    background: rgba(230, 241, 255, 0.5) !important;
    border-top: 1px solid rgba(30, 78, 140, 0.08) !important;
}

body.app-body .card-body {
    color: #002B45 !important;
}

/* ── 8. BOTÕES ─────────────────────────────────────────────────── */
body.app-body .btn-primary {
    background: #1E4E8C !important;
    border-color: #1E4E8C !important;
    color: #FFFFFF !important;
}

body.app-body .btn-primary:hover,
body.app-body .btn-primary:focus {
    background: #002B45 !important;
    border-color: #002B45 !important;
    color: #FFFFFF !important;
}

body.app-body .btn-outline-primary {
    background: #FFFFFF !important;
    color: #1E4E8C !important;
    border: 1px solid rgba(30, 78, 140, 0.28) !important;
}

body.app-body .btn-outline-primary:hover {
    background: #E6F1FF !important;
    color: #002B45 !important;
    border-color: #1E4E8C !important;
}

body.app-body .btn-outline-secondary {
    color: #68728B !important;
    border-color: rgba(30, 78, 140, 0.20) !important;
    background: #FFFFFF !important;
}

body.app-body .btn-outline-secondary:hover {
    background: #E6F1FF !important;
    color: #002B45 !important;
}

/* ── 9. INPUTS ─────────────────────────────────────────────────── */
body.app-body .form-control,
body.app-body .form-select {
    background: #FFFFFF !important;
    color: #002B45 !important;
    border: 1px solid rgba(30, 78, 140, 0.18) !important;
    border-radius: 10px !important;
}

body.app-body .form-control::placeholder {
    color: rgba(104, 114, 139, 0.65) !important;
}

body.app-body .form-control:focus,
body.app-body .form-select:focus {
    border-color: #5BA8FF !important;
    box-shadow: 0 0 0 3px rgba(91, 168, 255, 0.20) !important;
    background: #FFFFFF !important;
    color: #002B45 !important;
}

body.app-body .input-group-text {
    background: #EAF5FF !important;
    border-color: rgba(30, 78, 140, 0.18) !important;
    color: #1E4E8C !important;
}

body.app-body .form-label {
    color: #002B45;
    font-weight: 500;
}

/* ── 10. TABELAS ───────────────────────────────────────────────── */
body.app-body .table {
    color: #002B45 !important;
}

body.app-body .table thead th {
    background: rgba(230, 241, 255, 0.85) !important;
    color: #002B45 !important;
    font-weight: 600;
    border-bottom: 2px solid rgba(30, 78, 140, 0.12) !important;
    border-top: none !important;
}

body.app-body .table tbody td {
    color: #002B45 !important;
    border-color: rgba(30, 78, 140, 0.07) !important;
    vertical-align: middle;
}

body.app-body .table tbody tr:hover > td {
    background: rgba(230, 241, 255, 0.50) !important;
}

/* ── 11. MODAL ─────────────────────────────────────────────────── */
body.app-body .modal-content {
    background: #FFFFFF !important;
    color: #002B45 !important;
    border-radius: 18px !important;
    border: 1px solid rgba(30, 78, 140, 0.12) !important;
    box-shadow: 0 24px 64px rgba(0, 43, 69, 0.18) !important;
}

body.app-body .modal-header {
    border-bottom: 1px solid rgba(30, 78, 140, 0.12) !important;
}

body.app-body .modal-title {
    color: #002B45 !important;
}

body.app-body .modal-footer {
    border-top: 1px solid rgba(30, 78, 140, 0.10) !important;
    background: rgba(230, 241, 255, 0.3) !important;
}

/* ── 12. DROPDOWN ──────────────────────────────────────────────── */
body.app-body .dropdown-menu {
    background: #FFFFFF !important;
    border: 1px solid rgba(30, 78, 140, 0.12) !important;
    border-radius: 14px !important;
    box-shadow: 0 12px 32px rgba(0, 43, 69, 0.14) !important;
    padding: 6px !important;
}

body.app-body .dropdown-item {
    color: #002B45 !important;
    border-radius: 8px !important;
}

body.app-body .dropdown-item:hover,
body.app-body .dropdown-item:focus {
    background: #E6F1FF !important;
    color: #002B45 !important;
}

body.app-body .dropdown-divider {
    border-color: rgba(30, 78, 140, 0.10) !important;
}

/* ── 13. BADGES ────────────────────────────────────────────────── */
body.app-body .badge.bg-primary {
    background: #1E4E8C !important;
}

body.app-body .badge.bg-secondary {
    background: #68728B !important;
}

/* ── 14. ALERTAS ───────────────────────────────────────────────── */
body.app-body .alert {
    border-radius: 12px !important;
}

/* ── 15. CLASSES UTILITÁRIAS ───────────────────────────────────── */
.at-page {
    width: 100%;
}

.at-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.at-page-title {
    color: #002B45;
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin: 0;
    line-height: 1.2;
}

.at-page-subtitle {
    color: #68728B;
    font-size: 0.875rem;
    margin-top: 4px;
}

/* ── 16. GRID HELPERS ──────────────────────────────────────────── */
.at-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
}

.at-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

.at-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

@media (max-width: 1100px) {
    .at-grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .at-page-header {
        flex-direction: column;
        gap: 12px;
    }

    .at-grid-4,
    .at-grid-3,
    .at-grid-2 {
        grid-template-columns: 1fr;
    }
}

/* ── 17. HOME HERO — escopo navy, contraste claro ──────────────── */
/* Necessário aqui pois este arquivo carrega por último e os
   seletores globais acima usam !important com body.app-body       */

body.app-body .home-hero h1,
body.app-body .home-hero-txt h1 {
    color: #FFFFFF !important;
}

body.app-body .home-hero p,
body.app-body .home-hero-txt p {
    color: rgba(255, 255, 255, 0.80) !important;
}

body.app-body .home-hero .home-actions-cta {
    background: #FFFFFF !important;
    color: #002B45 !important;
    border-color: #FFFFFF !important;
}

body.app-body .home-hero .home-actions-cta:hover {
    background: #E6F1FF !important;
    color: #002B45 !important;
}

body.app-body .home-hero .home-actions-btn {
    background: rgba(255, 255, 255, 0.12) !important;
    color: #FFFFFF !important;
    border-color: rgba(255, 255, 255, 0.28) !important;
}

body.app-body .home-hero .home-actions-btn:hover {
    background: rgba(255, 255, 255, 0.22) !important;
    color: #FFFFFF !important;
    border-color: rgba(255, 255, 255, 0.45) !important;
}

body.app-body .home-hero .home-actions-btn i,
body.app-body .home-hero .home-actions-cta i {
    color: inherit !important;
}

/* ══════════════════════════════════════════════════════════════════
   18. MOBILE DRAWER — App Shell Mobile
   ══════════════════════════════════════════════════════════════════ */

/* ── Mobile header bar ─────────────────────────────────────────── */
.at-mobile-header {
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 60px;
    min-height: 60px;
    flex-shrink: 0;
    background: linear-gradient(90deg, #002B45 0%, #1E4E8C 100%);
    background: var(--at-gradient-brand, linear-gradient(90deg, #002B45 0%, #1E4E8C 100%));
    box-shadow: 0 2px 12px rgba(0, 43, 69, .22);
    position: sticky;
    top: 0;
    z-index: 1030;
}

.at-mobile-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none !important;
    color: #fff !important;
    flex-shrink: 0;
    min-width: 0;
}

.at-mobile-wordmark {
    font-size: 1rem;
    font-weight: 400;
    color: #fff;
    letter-spacing: .01em;
    white-space: nowrap;
}

.at-mobile-wordmark strong {
    font-weight: 700;
}

/* ── Hamburger button ──────────────────────────────────────────── */
.at-hamburger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    background: rgba(255, 255, 255, .10);
    border: 1.5px solid rgba(255, 255, 255, .22);
    border-radius: 10px;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: background .15s, border-color .15s;
    /* Reset: override .btn styles from custom.css */
    transform: none !important;
    box-shadow: none !important;
    overflow: visible;
    position: relative;
}

.at-hamburger:hover,
.at-hamburger:focus-visible {
    background: rgba(255, 255, 255, .20);
    border-color: rgba(255, 255, 255, .40);
    outline: none;
}

.at-hamburger:focus-visible {
    outline: 2px solid rgba(91, 168, 255, .8);
    outline-offset: 2px;
}

.at-hamburger-bar {
    display: block;
    width: 20px;
    height: 2px;
    background: #ffffff;
    border-radius: 2px;
    transition: transform .2s ease, opacity .2s ease;
    pointer-events: none;
}

/* ── Drawer (off-canvas) ───────────────────────────────────────── */
.at-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: min(82vw, 300px);
    height: 100dvh;
    height: 100vh; /* fallback */
    background: #002B45;
    z-index: 1100;
    transform: translateX(-100%);
    transition: transform .26s cubic-bezier(.4, 0, .2, 1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 24px 0 60px rgba(0, 0, 0, .25);
    /* Ensure it's always hidden on desktop */
    visibility: hidden;
}

@media (min-width: 992px) {
    .at-drawer {
        display: none !important;
    }

    .at-backdrop {
        display: none !important;
    }

    .at-mobile-header {
        display: none !important;
    }
}

@media (max-width: 991px) {
    .at-drawer {
        visibility: visible;
    }
}

body.at-drawer-open .at-drawer {
    transform: translateX(0);
}

/* ── Drawer header ─────────────────────────────────────────────── */
.at-drawer-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .10);
    flex-shrink: 0;
    min-height: 64px;
}

.at-drawer-close {
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 8px;
    color: rgba(255, 255, 255, .75);
    font-size: .95rem;
    cursor: pointer;
    transition: background .15s, color .15s;
    padding: 0;
    /* Reset custom.css .btn styles */
    transform: none !important;
    box-shadow: none !important;
    overflow: visible;
}

.at-drawer-close:hover,
.at-drawer-close:focus-visible {
    background: rgba(255, 255, 255, .16);
    color: #fff;
    outline: none;
}

.at-drawer-close:focus-visible {
    outline: 2px solid rgba(91, 168, 255, .8);
    outline-offset: 2px;
}

/* ── Drawer nav links ──────────────────────────────────────────── */
.at-drawer-nav {
    padding: 10px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.at-drawer-link {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 12px 14px;
    color: rgba(255, 255, 255, .80) !important;
    text-decoration: none !important;
    border-radius: 10px;
    font-size: .9rem;
    font-weight: 500;
    transition: background .15s, color .15s;
    min-height: 46px;
    /* Reset btn overrides */
    transform: none !important;
    box-shadow: none !important;
    overflow: visible;
    white-space: nowrap;
    letter-spacing: normal;
    justify-content: flex-start;
    cursor: pointer;
}

.at-drawer-link:hover {
    background: rgba(91, 168, 255, .16) !important;
    color: #fff !important;
}

.at-drawer-link:focus-visible {
    outline: 2px solid rgba(91, 168, 255, .8);
    outline-offset: -2px;
    background: rgba(91, 168, 255, .12) !important;
}

.at-drawer-link.active {
    background: rgba(91, 168, 255, .22) !important;
    color: #5BA8FF !important;
}

.at-drawer-link i {
    width: 18px;
    min-width: 18px;
    text-align: center;
    font-size: .95rem;
    flex-shrink: 0;
    color: inherit;
}

/* ── Drawer user section ───────────────────────────────────────── */
.at-drawer-divider {
    height: 1px;
    background: rgba(255, 255, 255, .10);
    margin: 6px 12px;
    flex-shrink: 0;
}

.at-drawer-user-section {
    padding: 8px 12px 16px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.at-drawer-master-badge {
    font-size: .72rem;
    color: rgba(255, 255, 255, .50);
    padding: 4px 14px;
    margin-bottom: 2px;
}

.at-drawer-profile {
    padding: 10px 14px !important;
}

.at-drawer-avatar {
    width: 30px;
    height: 30px;
    min-width: 30px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, .28);
    flex-shrink: 0;
}

.at-drawer-initials {
    width: 30px;
    height: 30px;
    min-width: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .65rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.at-drawer-user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.at-drawer-user-name {
    font-size: .85rem;
    font-weight: 600;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.at-drawer-user-role {
    font-size: .72rem;
    color: rgba(255, 255, 255, .50);
}

.at-drawer-logout {
    color: rgba(255, 255, 255, .60) !important;
}

.at-drawer-logout:hover {
    color: #fff !important;
    background: rgba(220, 53, 69, .18) !important;
}

/* ── Backdrop ──────────────────────────────────────────────────── */
.at-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .50);
    z-index: 1090;
    opacity: 0;
    pointer-events: none;
    transition: opacity .26s ease;
}

body.at-drawer-open .at-backdrop {
    opacity: 1;
    pointer-events: auto;
}

/* ── Mobile container adjustments ─────────────────────────────── */
@media (max-width: 767px) {
    .at-app-container {
        width: 100% !important;
        padding: 16px 16px 32px !important;
    }

    .at-page-header {
        flex-direction: column;
        gap: 12px;
        margin-bottom: 20px;
    }

    .at-page-title {
        font-size: 1.4rem;
    }

    /* Prevent body-level horizontal scroll from wide content */
    body.app-body {
        overflow-x: hidden;
    }

    /* Table overflow safety net */
    body.app-body .table-auto-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .app-footer .row {
        gap: 16px;
    }

    /* analytics-summary-grid responsive */
    #analytics-dashboard-page .analytics-summary-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}
