/* ===== IMOBILIARIAS PG - PREMIUM UI/UX ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --dark: #0f172a;
    --sidebar-bg: #1e293b;
    --body-bg: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--body-bg);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Layout */
.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: #fff;
    height: 100vh;
    position: fixed;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.sidebar-logo {
    padding: 24px;
    font-size: 1.5rem;
    font-weight: 800;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-nav { padding: 16px; flex: 1; overflow-y: auto; transition: all 0.3s ease; }

/* Customização da Scrollbar */
.sidebar-nav::-webkit-scrollbar {
    width: 8px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: #1e293b;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background-color: #4f46e5;
    border-radius: 10px;
    border: 2px solid #1e293b;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background-color: #4338ca;
}

/* Nav Group (Accordion) */
.nav-group { margin-bottom: 8px; }
.nav-group-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: #94a3b8;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius);
    transition: all 0.2s;
}
.nav-group-header:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav-group.active .nav-group-header { color: #fff; }
.nav-group-header i:first-child { margin-right: 12px; width: 20px; }
.chevron { font-size: 0.75rem; transition: transform 0.2s; }
.nav-group.active .chevron { transform: rotate(180deg); }

.nav-group-content {
    display: none;
    padding: 4px 0 4px 32px;
}
.nav-group.active .nav-group-content { display: block; }

.nav-sub-item {
    display: block;
    padding: 8px 16px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.875rem;
    border-radius: var(--radius);
    transition: all 0.2s;
}
.nav-sub-item:hover { color: #fff; background: rgba(255,255,255,0.05); }
.nav-sub-item.active { color: var(--primary); font-weight: 700; }

.nav-item-single {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: #94a3b8;
    text-decoration: none;
    font-weight: 600;
    border-radius: var(--radius);
    margin-bottom: 4px;
    transition: all 0.2s;
}
.nav-item-single:hover, .nav-item-single.active { background: rgba(255,255,255,0.05); color: #fff; }
.nav-item-single i { margin-right: 12px; width: 20px; display: inline-flex; align-items: center; justify-content: center; }
.nav-item-single.active { color: var(--primary); position: relative; }
.app-layout.sidebar-collapsed .nav-item-single.active {
    background: transparent !important;
    color: #fff !important;
    border: none !important;
    box-shadow: none !important;
}

.sidebar-bottom { padding: 16px; border-top: 1px solid rgba(255,255,255,0.1); margin-top: auto; }

/* Main Content */
.main-content { flex: 1; margin-left: 260px; transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1); }

/* Estado Recolhido da Sidebar */
.app-layout.sidebar-collapsed .sidebar {
    width: 60px;
}

.app-layout.sidebar-collapsed .main-content {
    margin-left: 60px;
}

.app-layout.sidebar-collapsed .sidebar-logo span {
    display: none;
}

.app-layout.sidebar-collapsed .sidebar-logo {
    justify-content: center;
    padding: 24px 12px;
}

.app-layout.sidebar-collapsed .sidebar-logo img {
    height: 32px;
}

.app-layout.sidebar-collapsed .sidebar-nav .nav-item-single {
    justify-content: center;
    padding: 12px 8px;
}

/* Removido para usar opacidade */

.nav-item-single span, 
.nav-group-header span,
.sidebar-logo span {
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.2s ease, visibility 0.2s;
}

.app-layout.sidebar-collapsed .nav-item-single span,
.app-layout.sidebar-collapsed .nav-group-header span,
.app-layout.sidebar-collapsed .sidebar-logo span {
    opacity: 0;
    visibility: hidden;
    width: 0;
    height: 0;
    display: inline-block;
    overflow: hidden;
}

.app-layout.sidebar-collapsed .sidebar-nav .nav-group-header {
    justify-content: center;
    padding: 12px 8px;
}

/* O texto já é tratado pela regra acima */

.app-layout.sidebar-collapsed .sidebar-nav .nav-group-header i:first-child {
    margin-right: 0;
    width: auto;
}

.app-layout.sidebar-collapsed .sidebar-nav .nav-group-header .chevron {
    display: none;
}

.app-layout.sidebar-collapsed .sidebar-nav .nav-group-content {
    display: none !important;
}

.app-layout.sidebar-collapsed .sidebar-bottom {
    padding: 16px 8px;
}

.app-layout.sidebar-collapsed .sidebar-bottom .nav-item-single {
    justify-content: center;
    padding: 12px 8px;
}

.app-layout.sidebar-collapsed .sidebar-bottom .nav-item-single i {
    margin-right: 0;
    width: auto;
}

/* Remover pseudo-elemento azul do item ativo quando recolhido */
.app-layout.sidebar-collapsed .nav-item-single.active::before {
    display: none !important;
}

/* O texto ja e tratado pela transicao de opacidade */

/* Botão Toggle Sidebar */
.btn-toggle-sidebar {
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-toggle-sidebar:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--primary);
}

.mobile-only { display: none; }
@media (max-width: 768px) {
    .mobile-only { display: flex; }
    .desktop-only { display: none; }
}

.topbar {
    height: 64px;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
}

.content-body { padding: 32px; max-width: 1200px; margin: 0 auto; }

.page-header { margin-bottom: 24px; display: flex; justify-content: space-between; align-items: center; }
.page-header h1 { font-size: 1.875rem; font-weight: 700; color: var(--dark); }
.page-header p { color: var(--text-muted); }

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 24px;
}
.card-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-title { font-weight: 700; color: var(--dark); font-size: 1.125rem; }
.card-body { padding: 24px; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    font-size: 0.875rem;
    gap: 8px;
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { border-color: var(--border-color); background: #fff; color: var(--text-main); }
.btn-outline:hover { background: #f8fafc; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-text { background: transparent; color: var(--text-muted); padding: 5px; }
.btn-text:hover { color: var(--primary); }
.btn-full { width: 100%; }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 6px; }
.form-control, input[type="text"], input[type="password"], input[type="email"], input[type="number"], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.875rem;
    transition: border-color 0.2s;
    font-family: inherit;
}
.form-control:focus, input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); }

/* Modais Reais */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}
.modal.active { display: flex; }
.modal-content {
    background: #fff;
    border-radius: var(--radius);
    width: 100%;
    max-width: 500px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-title { font-size: 1.125rem; font-weight: 700; color: var(--dark); }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border-color); display: flex; gap: 10px; justify-content: flex-end; }

/* Auth Pages (Login/Register) */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    padding: 20px;
}
.auth-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 40px;
    border-radius: 24px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
    color: #fff;
}
.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo h1 { font-size: 2rem; font-weight: 800; color: #fff; }
.auth-logo p { color: #94a3b8; font-size: 0.875rem; margin-top: 8px; }
.auth-card label { color: #e2e8f0; }
.auth-card input { background: rgba(0,0,0,0.2); border: 1px solid rgba(255,255,255,0.1); color: #fff; }
.auth-card input:focus { background: rgba(0,0,0,0.3); border-color: var(--primary); }

/* Table Style */
.table-responsive { overflow-x: auto; border-radius: 8px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 12px 16px; border-bottom: 2px solid var(--border-color); color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }
td { padding: 16px; border-bottom: 1px solid var(--border-color); font-size: 0.875rem; vertical-align: middle; }
tr:hover { background: #f8fafc; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; font-size: 0.875rem; font-weight: 500; border: 1px solid transparent; display: flex; align-items: center; gap: 10px; }
.alert-error { background: #fef2f2; border-color: #fee2e2; color: #b91c1c; }
.alert-success { background: #f0fdf4; border-color: #dcfce7; color: #15803d; }
.alert-info { background: #eff6ff; border-color: #dbeafe; color: #1e40af; }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 99px; font-size: 0.75rem; font-weight: 600; }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger { background: #fef2f2; color: #b91c1c; }
.badge-warning { background: #fffbeb; color: #92400e; }
.badge-outline { border: 1px solid var(--border-color); color: var(--text-muted); }

/* Loader */
.loader { width: 40px; height: 40px; border: 4px solid #f3f3f3; border-top: 4px solid var(--primary); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Utility */
.text-center { text-align: center; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }

/* Responsividade Melhorada */
@media (max-width: 1200px) {
    .sidebar {
        width: 240px;
    }
    .main-content {
        margin-left: 240px;
    }
    .topbar {
        padding: 0 24px;
    }
    .content-body {
        padding: 24px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 260px;
        transition: transform 0.3s ease;
    }
    .app-layout.sidebar-mobile-open .sidebar {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0 !important;
        width: 100%;
    }
    .topbar {
        padding: 0 12px;
        height: 60px;
        position: sticky;
        top: 0;
        z-index: 999;
    }
    .content-body {
        padding: 12px;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 16px;
    }
    .page-header h1 {
        font-size: 1.3rem;
    }

    /* Topbar direita: compactar elementos */
    .topbar-right-inner {
        gap: 10px !important;
    }

    /* Badge de pontos: compactar */
    .wallet-badge {
        padding: 4px 8px !important;
        gap: 6px !important;
    }
    .wallet-badge span[style*="font-size:14px"] {
        font-size: 13px !important;
    }
    .wallet-badge span[style*="font-size:10px"] {
        display: none !important;
    }

    /* Nome do usuário: ocultar em telas muito pequenas */
    .username-display {
        display: none;
    }

    /* Painel de notificações: não ultrapassar a tela */
    #notificationPanel {
        width: calc(100vw - 24px) !important;
        right: -10px !important;
        max-width: 320px !important;
    }

    /* Grid adjustments for mobile */
    .dashboard-grid, .stats-grid, .filters-grid, .results-grid {
        grid-template-columns: 1fr !important;
    }

    /* Grids inline de 2 colunas no dashboard e páginas internas */
    div[style*="grid-template-columns: 2fr 1fr"],
    div[style*="grid-template-columns: 1fr 1fr"],
    div[style*="grid-template-columns:1fr 1fr"],
    div[style*="grid-template-columns:2fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Grids de 3 e 4 colunas */
    div[style*="grid-template-columns: 1fr 1fr 1fr"],
    div[style*="grid-template-columns:1fr 1fr 1fr"],
    div[style*="grid-template-columns: repeat(4"],
    div[style*="grid-template-columns:repeat(4"],
    div[style*="grid-template-columns: repeat(3"],
    div[style*="grid-template-columns:repeat(3"] {
        grid-template-columns: 1fr !important;
    }

    /* Bot Automation specific */
    div[style*="display:grid; grid-template-columns: 1fr 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    .card-body {
        padding: 12px;
    }

    /* Botões: não forçar 100% em todos os contextos, apenas em page-header e card-header */
    .page-header .btn,
    .card-header .btn {
        width: auto;
    }

    /* Modais: garantir que não ultrapassem a tela */
    .modal-content {
        width: 95% !important;
        max-width: 95vw !important;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* Modal footer: empilhar botões */
    .modal-footer {
        flex-wrap: wrap;
        gap: 8px;
    }
    .modal-footer .btn {
        flex: 1;
        min-width: 120px;
    }

    /* Tabelas: garantir scroll horizontal */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Card header com flex: empilhar em mobile */
    .card-header {
        flex-wrap: wrap;
        gap: 8px;
    }
}

/* ===== DASHBOARD MOBILE ===== */
@media (max-width: 768px) {
    .dashboard-main-grid {
        grid-template-columns: 1fr !important;
    }

    /* Ações rápidas: manter 2 colunas no mobile (ficam bem) */
    .dashboard-main-grid .card-body[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr 1fr !important;
    }

    /* Botões de ação rápida: padding menor no mobile */
    .dashboard-main-grid .btn[style*="padding:30px"] {
        padding: 16px 10px !important;
        font-size: 12px;
    }
}

/* ===== RENTAL MANAGEMENT MOBILE ===== */
@media (max-width: 768px) {
    /* Modal de locação: grids internos */
    #modalRental .modal-content {
        width: 98% !important;
        max-width: 98vw !important;
    }

    /* Grids com repeat(4, 1fr) e repeat(3, 1fr) dentro de modais */
    #modalRental div[style*="grid-template-columns:repeat(4"],
    #modalRental div[style*="grid-template-columns: repeat(4"],
    #modalRental div[style*="grid-template-columns:repeat(3"],
    #modalRental div[style*="grid-template-columns: repeat(3"] {
        grid-template-columns: 1fr 1fr !important;
    }

    /* Pix fields: manter 2 colunas */
    #f_pixFields {
        grid-template-columns: 1fr 1fr !important;
    }

    /* Cabeçalho da tabela de locações: scroll horizontal */
    .rental-row td:nth-child(3),
    .rental-row td:nth-child(4) {
        display: none;
    }
}

/* ===== MANAGE EMPLOYEES MOBILE ===== */
@media (max-width: 768px) {
    /* Tabela de funcionários: scroll horizontal */
    #manage-employees-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Modais de funcionários */
    #modal-add-employee .modal-content,
    #modal-edit-employee .modal-content {
        width: 95% !important;
        max-width: 95vw !important;
    }

    /* Permissões: 1 coluna no mobile */
    #modal-add-employee div[style*="grid-template-columns: 1fr 1fr"],
    #modal-edit-employee div[style*="grid-template-columns: 1fr 1fr"],
    #modal-add-employee div[style*="grid-template-columns:1fr 1fr"],
    #modal-edit-employee div[style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

/* ===== PAGE HEADER COM BOTÕES MOBILE ===== */
@media (max-width: 768px) {
    /* Page headers com flex interno */
    .page-header > div[style*="display:flex"],
    .page-header[style*="display:flex"] {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
        width: 100%;
    }

    /* Grupo de botões no page-header */
    .page-header div[style*="display:flex; gap"] {
        flex-wrap: wrap;
        gap: 8px !important;
    }

    .page-header .btn {
        width: auto !important;
        margin-bottom: 0 !important;
    }

    /* Filtros de tabela: empilhar */
    .card div[style*="display:flex; justify-content:space-between"] {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 10px;
    }

    .card div[style*="display:flex; justify-content:space-between"] select {
        width: 100% !important;
    }
}

/* ===== SUPPORT PAGE MOBILE ===== */
@media (max-width: 768px) {
    /* Grid 1fr 2fr do suporte */
    div[style*="grid-template-columns: 1fr 2fr"],
    div[style*="grid-template-columns:1fr 2fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Tickets: empilhar conteúdo e botões */
    div[style*="display: flex; justify-content: space-between; align-items: center"] {
        flex-wrap: wrap;
        gap: 10px;
    }
}

/* ===== BOT AUTOMATION MOBILE ===== */
@media (max-width: 768px) {
    /* Toggle bar do bot */
    #bot-toggle-bar {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
    }

    #btn-toggle-bot {
        width: 100% !important;
        min-width: unset !important;
    }

    /* Grid 3 colunas do bot */
    div[style*="grid-template-columns: 1fr 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

/* ===== AUTOMATION PAGES MOBILE ===== */
@media (max-width: 768px) {
    /* Grids 1fr 1fr das páginas de automação */
    div[style*="display:grid; grid-template-columns: 1fr 1fr; gap: 24px"] {
        grid-template-columns: 1fr !important;
    }
}

/* ===== SETTINGS PAGE MOBILE ===== */
@media (max-width: 768px) {
    /* Grid principal de settings */
    div[style*="grid-template-columns: 1fr 1fr; gap: 24px"] {
        grid-template-columns: 1fr !important;
    }

    /* Card span 2 em mobile: voltar para span 1 */
    .card[style*="grid-column: span 2"] {
        grid-column: span 1 !important;
    }

    /* Bloco de equipe: empilhar */
    div[style*="display:flex; gap:40px"] {
        flex-direction: column !important;
        gap: 16px !important;
        align-items: flex-start !important;
    }
}

/* ===== BUY POINTS / BUY EMPLOYEES MOBILE ===== */
@media (max-width: 768px) {
    /* Modal PIX: linha input + botão */
    div[style*="display:flex; gap:8px"] {
        flex-wrap: wrap;
    }

    div[style*="display:flex; gap:8px"] input {
        flex: 1;
        min-width: 0;
    }

    /* QR code: garantir que não ultrapasse a tela */
    img[style*="width:200px"] {
        max-width: 100%;
    }
}

/* ===== TOPBAR COMPACTA MOBILE ===== */
@media (max-width: 480px) {
    /* Em telas muito pequenas, ocultar texto do botão sair */
    .topbar-right a[style*="font-size:12px"] span,
    .topbar-right a.btn .fa-right-from-bracket + * {
        display: none;
    }

    /* Reduzir padding do topbar ainda mais */
    .topbar {
        padding: 0 8px !important;
    }

    .content-body {
        padding: 8px !important;
    }
}

/* ===== RENTAL MANAGEMENT MODAL ESPECÍFICO ===== */
@media (max-width: 768px) {
    /* Modal principal de locação */
    #modalRental .modal-content {
        width: 98vw !important;
        max-width: 98vw !important;
        margin: 4px !important;
    }

    /* Grid repeat(4) → 2 colunas no mobile */
    #modalRental div[style*="grid-template-columns:repeat(4, 1fr)"],
    #modalRental div[style*="grid-template-columns: repeat(4, 1fr)"] {
        grid-template-columns: 1fr 1fr !important;
    }

    /* Grid repeat(3) → 1 coluna no mobile */
    #modalRental div[style*="grid-template-columns:repeat(3, 1fr)"],
    #modalRental div[style*="grid-template-columns: repeat(3, 1fr)"] {
        grid-template-columns: 1fr !important;
    }

    /* Modal footer do rental: empilhar botões */
    #modalRental .modal-footer,
    #modalRental div[style*="modal-footer"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
    }

    #modalRental .modal-footer .btn,
    #modalRental div[style*="text-align:right"] .btn {
        width: 100% !important;
    }
}

/* ===== LEADS FILTROS MOBILE ===== */
@media (max-width: 768px) {
    /* Formulário de filtros em flex: empilhar */
    .card form[style*="display:flex"] {
        flex-direction: column !important;
        gap: 12px !important;
        align-items: stretch !important;
    }

    .card form[style*="display:flex"] .form-group {
        flex: none !important;
        width: 100% !important;
    }

    .card form[style*="display:flex"] .btn {
        width: 100% !important;
    }
}

/* ===== DOCUMENTAÇÃO MOBILE (rental_contract, sales_contract, etc.) ===== */
@media (max-width: 768px) {
    /* Botões de tipo de contrato: empilhar */
    div[style*="display: grid; grid-template-columns: 1fr 1fr; gap: 20px"] .card {
        padding: 20px !important;
    }

    /* Botões de ação final (Voltar + Gerar): empilhar */
    div[style*="display: flex; gap: 15px"] .btn[style*="flex: 1"],
    div[style*="display: flex; gap: 15px"] .btn[style*="flex: 2"] {
        flex: 1 !important;
    }
}

/* ===== SEARCH PAGES MOBILE ===== */
@media (max-width: 768px) {
    /* Botões de consulta PF/PJ: manter 2 colunas (ficam bem) */
    div[style*="display:grid; grid-template-columns: 1fr 1fr; gap:15px"] {
        grid-template-columns: 1fr 1fr !important;
    }
}

/* ===== GERAL: OVERFLOW PREVENTION ===== */
@media (max-width: 768px) {
    /* Prevenir overflow horizontal em qualquer elemento */
    .content-body * {
        max-width: 100%;
        word-break: break-word;
    }

    /* Exceto imagens e ícones */
    .content-body img,
    .content-body i,
    .content-body svg {
        max-width: none;
        word-break: normal;
    }

    /* Inputs e textareas: garantir que não ultrapassem */
    input, textarea, select {
        max-width: 100% !important;
    }
}

/* ===== VIEW TICKET MOBILE ===== */
@media (max-width: 768px) {
    /* Cabeçalho do ticket: empilhar */
    div[style*="max-width: 900px"] > div[style*="display: flex; justify-content: space-between"] {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }

    /* Bolhas de mensagem: max-width maior no mobile */
    div[style*="max-width: 80%"] {
        max-width: 90% !important;
    }
}

/* ===== CONTENT-HEADER MOBILE (support.php) ===== */
@media (max-width: 768px) {
    .content-header {
        margin-bottom: 20px !important;
    }

    .content-header h1 {
        font-size: 22px !important;
    }
}

/* ===== GARANTIA FINAL: PREVENIR OVERFLOW HORIZONTAL ===== */
html, body {
    overflow-x: hidden;
}

@media (max-width: 768px) {
    .app-layout {
        overflow-x: hidden;
    }

    .main-content {
        overflow-x: hidden;
    }
}
