/* =====================================================================
   LSW - Admin Theme CSS
   Layout estilo AdminLTE com sidebar, topbar e cards
   ===================================================================== */

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 0px;
    --topbar-height: 64px;
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --sidebar-bg: #1e293b;
    --sidebar-bg-hover: #334155;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #2563eb;
    --content-bg: #f1f5f9;
    --card-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --transition: all .2s ease-in-out;
}

* { box-sizing: border-box; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--content-bg); margin: 0; }

/* ===================== AUTH PAGES ===================== */
.auth-page {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.auth-wrapper { width: 100%; max-width: 440px; }
.auth-card {
    background: #fff; border-radius: 16px; padding: 2.5rem; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.auth-brand { text-align: center; margin-bottom: 2rem; }
.auth-brand a { text-decoration: none; color: #1e293b; display: inline-flex; align-items: center; gap: .5rem; }
.brand-icon {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff; width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center; font-size: 1.5rem;
}
.brand-text { font-size: 1.5rem; font-weight: 700; }
.auth-header { text-align: center; margin-bottom: 1.5rem; }
.auth-header h2 { font-weight: 700; color: #1e293b; margin-bottom: .25rem; }
.auth-header p { color: #64748b; margin: 0; }
.auth-form .form-control-lg { padding: .75rem 1rem; border-radius: 10px; }
.auth-form .form-floating > label { padding-left: 1rem; }
.btn-primary {
    background: var(--primary); border-color: var(--primary);
    border-radius: 10px; font-weight: 600; transition: var(--transition);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); transform: translateY(-1px); }
.btn-toggle-password {
    position: absolute; right: 1rem; top: 50%; transform: translateY(-50%);
    background: none; border: none; color: #64748b; cursor: pointer; padding: .25rem;
}
.auth-footer { text-align: center; margin-top: 1.5rem; }
.auth-footer a { color: #64748b; text-decoration: none; font-size: .875rem; }
.auth-demo-creds { margin-top: 1.5rem; text-align: center; }
.creds-box { background: #f1f5f9; padding: .5rem; border-radius: 6px; margin-top: .5rem; }

/* ===================== APP LAYOUT ===================== */
.app-wrapper { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width); background: var(--sidebar-bg);
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 1030;
    display: flex; flex-direction: column;
    transition: transform .3s ease;
}
.sidebar-header {
    height: var(--topbar-height); padding: 0 1.25rem;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand { display: flex; align-items: flex-start; gap: .625rem; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.sidebar-brand .brand-icon { width: 36px; height: 36px; font-size: 1.1rem; border-radius: 8px; flex: 0 0 auto; }
.sidebar-brand .brand-text { white-space: normal; overflow: visible; word-break: break-word; overflow-wrap: break-word; line-height: 1.2; flex: 1 1 auto; min-width: 0; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 1rem 0; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 3px; }

.nav-list, .nav-sublist { list-style: none; padding: 0; margin: 0; }
.nav-sublist { background: rgba(0,0,0,.2); padding: .25rem 0; }
.nav-link {
    display: flex; align-items: center; gap: .75rem; padding: .7rem 1.25rem;
    color: var(--sidebar-text); text-decoration: none; font-size: .925rem;
    transition: var(--transition); border-left: 3px solid transparent; cursor: pointer;
}
.nav-link:hover { background: var(--sidebar-bg-hover); color: #fff; }
.nav-link.active { background: rgba(37,99,235,.2); color: #fff; border-left-color: var(--sidebar-active); }
.nav-link i:first-child { font-size: 1.15rem; width: 24px; text-align: center; }
.nav-text { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-arrow { font-size: .75rem; transition: transform .2s; }
.nav-dropdown.open .nav-arrow { transform: rotate(180deg); }
.nav-dropdown .nav-sublist { display: none; }
.nav-dropdown.open .nav-sublist { display: block; }
.nav-sublist .nav-link { padding-left: 3.5rem; font-size: .875rem; }

/* Rótulo do menu pai (ex.: "Sistema") sempre visível.
   - O .nav-text nunca colapsa/_some (min-width:0 + nowrap + ellipsis).
   - Com o submenu aberto, o link pai fica "grudado" no topo da área
     rolável do sidebar, com fundo sólido e z-index acima da sublista,
     para o rótulo permanecer legível por cima dos itens ao rolar. */
.sidebar .nav-dropdown.open > .nav-link {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--sidebar-bg-hover);
}

/* Estados de interação (hover/foco) com contraste garantido.
   Prefixar com .sidebar dá especificidade (0,3,0) MAIOR que as regras
   .nav-link:hover do Bootstrap (0,2,0), garantindo texto branco e fundo
   claramente mais claro que o fundo do sidebar — o item nunca some. */
.sidebar .nav-link:hover,
.sidebar .nav-link:focus {
    background: #475569;              /* slate-600: destaque visível sobre #1e293b */
    color: #fff;
    border-left-color: var(--primary);
}
.sidebar .nav-link:hover .nav-text,
.sidebar .nav-link:focus .nav-text { color: #fff; }
.sidebar-footer { padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-footer .btn { color: #fff; border-color: rgba(255,255,255,.2); }
.sidebar-footer .btn:hover { background: rgba(255,255,255,.1); }

/* Main wrapper */
.main-wrapper {
    flex: 1; margin-left: var(--sidebar-width);
    display: flex; flex-direction: column; min-height: 100vh;
}

/* Topbar */
.topbar {
    height: var(--topbar-height); background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
    display: flex; align-items: center; padding: 0 1.5rem;
    position: sticky; top: 0; z-index: 1020; gap: 1rem;
}
.sidebar-toggle-btn { color: #475569; text-decoration: none; font-size: 1.5rem; padding: .5rem; }
.breadcrumbs { display: flex; align-items: center; gap: .5rem; font-size: .875rem; }
.breadcrumbs a, .breadcrumbs span { color: #64748b; text-decoration: none; }
.breadcrumbs a:hover { color: var(--primary); }
.breadcrumbs .current { color: #1e293b; font-weight: 600; }
.breadcrumbs .sep { font-size: .75rem; opacity: .5; }
.topbar-actions { display: flex; align-items: center; gap: .5rem; }
.topbar-search { position: relative; }
.topbar-search .input-group { background: #f1f5f9; border-radius: 8px; overflow: hidden; }
.topbar-search .input-group-text { background: transparent; border: 0; color: #94a3b8; }
.topbar-search .form-control { background: transparent; border: 0; }
.topbar-search .form-control:focus { box-shadow: none; }

/* Busca global — dropdown de resultados */
.global-search-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 340px;
    z-index: 1060;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(2, 6, 23, .14);
    padding: .25rem 0;
    max-height: 65vh;
    overflow-y: auto;
}
.gs-group-title {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: #94a3b8;
    padding: .5rem .85rem .25rem;
}
.gs-item {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .5rem .85rem;
    color: #1e293b;
    text-decoration: none;
}
.gs-item:hover, .gs-item.active { background: #f1f5f9; color: var(--primary); }
.gs-item .gs-icon { font-size: 1.05rem; color: #94a3b8; }
.gs-item:hover .gs-icon, .gs-item.active .gs-icon { color: var(--primary); }
.gs-item .gs-title { font-weight: 600; font-size: .865rem; }
.gs-item .gs-sub { font-size: .75rem; color: #64748b; }
.gs-empty { padding: .9rem .85rem; font-size: .85rem; color: #64748b; text-align: center; }

.topbar-icon-dropdown { position: relative; }
.topbar-icon {
    background: transparent; border: 0; color: #475569; font-size: 1.4rem;
    padding: .5rem; border-radius: 50%; cursor: pointer; position: relative; transition: var(--transition);
}
.topbar-icon:hover { background: #f1f5f9; color: var(--primary); }
.badge-count {
    position: absolute; top: 2px; right: 2px; font-size: .65rem;
    min-width: 18px; height: 18px; display: flex; align-items: center; justify-content: center;
    border-radius: 9px; padding: 0 4px;
}
.notification-menu { width: 360px; padding: 0; border: 0; box-shadow: 0 10px 40px rgba(0,0,0,.15); border-radius: 12px; overflow: hidden; }
.notification-list { max-height: 350px; overflow-y: auto; }
.notification-item {
    display: flex; gap: .75rem; padding: .875rem 1rem; text-decoration: none; color: inherit;
    border-bottom: 1px solid #f1f5f9;
}
.notification-item:hover { background: #f8fafc; }
.notification-item.unread { background: #eff6ff; }
.notif-icon { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; }
.bg-light-primary { background: #dbeafe; color: var(--primary); }
.bg-light-success { background: #dcfce7; color: #16a34a; }
.bg-light-info { background: #cffafe; color: #0891b2; }
.bg-light-warning { background: #fef3c7; color: #d97706; }
.bg-light-danger { background: #fee2e2; color: #dc2626; }
.notif-content p { margin: 0; font-size: .8rem; color: #64748b; }
.notif-content small { font-size: .7rem; }
.notification-empty { text-align: center; padding: 2rem; color: #94a3b8; }
.notification-empty i { font-size: 2.5rem; opacity: .5; }

.topbar-user {
    display: flex; align-items: center; gap: .5rem;
    background: transparent; border: 0; padding: .375rem .5rem; border-radius: 8px; cursor: pointer;
}
.topbar-user:hover { background: #f1f5f9; }
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: .85rem;
}
.user-name { font-size: .875rem; font-weight: 600; color: #1e293b; }

/* Content */
.content { flex: 1; padding: 1.5rem; }
.page-header { margin-bottom: 1.5rem; }
.page-title { font-size: 1.5rem; font-weight: 700; color: #1e293b; margin: 0; }

/* Footer */
.footer {
    padding: 1rem 1.5rem; background: #fff; border-top: 1px solid #e2e8f0;
    display: flex; justify-content: space-between; align-items: center; font-size: .8rem; color: #64748b;
}

/* ===================== COMPONENTS ===================== */

/* Stat cards */
.stat-card {
    background: #fff; border-radius: 12px; padding: 1.25rem;
    display: flex; align-items: center; gap: 1rem;
    box-shadow: var(--card-shadow); border-left: 4px solid;
    transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.border-primary { border-left-color: var(--primary) !important; }
.border-success { border-left-color: #16a34a !important; }
.border-info { border-left-color: #0891b2 !important; }
.border-warning { border-left-color: #f59e0b !important; }
.border-danger { border-left-color: #dc2626 !important; }
.stat-icon { width: 56px; height: 56px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; flex-shrink: 0; }
.stat-info { flex: 1; min-width: 0; }
.stat-label { font-size: .75rem; color: #64748b; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: #1e293b; line-height: 1.2; margin: .15rem 0; }
.stat-sub { font-size: .75rem; }

/* Cards */
.card { border: 0; border-radius: 12px; box-shadow: var(--card-shadow); }
.card-header { background: #fff; border-bottom: 1px solid #e2e8f0; padding: 1rem 1.25rem; border-radius: 12px 12px 0 0 !important; }
.card-title { font-size: 1rem; font-weight: 600; color: #1e293b; }
.card-body { padding: 1.25rem; }

/* Avatar small */
.avatar-sm { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1rem; flex-shrink: 0; }

/* Visit date */
.visit-date {
    background: var(--primary); color: #fff; border-radius: 8px; padding: .5rem .625rem;
    text-align: center; min-width: 50px;
}
.visit-date .day { font-size: 1.25rem; font-weight: 700; line-height: 1; }
.visit-date .month { font-size: .65rem; opacity: .9; }

/* Buttons */
.btn { border-radius: 8px; font-weight: 500; }
.btn-sm { border-radius: 6px; }
.btn-icon { width: 36px; height: 36px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }

/* Badges */
.badge { font-weight: 500; padding: .35em .6em; border-radius: 6px; }

/* Tables */
.table { margin: 0; }
.table thead th { background: #f8fafc; border-bottom: 2px solid #e2e8f0; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: #64748b; font-weight: 600; }
.table-hover tbody tr:hover { background: #f8fafc; cursor: pointer; }

/* Forms */
.form-label { font-weight: 600; color: #475569; font-size: .875rem; margin-bottom: .375rem; }
.form-control, .form-select { border-radius: 8px; border-color: #e2e8f0; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 .2rem rgba(37,99,235,.15); }
.form-text { font-size: .75rem; color: #94a3b8; }
.required::after { content: " *"; color: #dc2626; }

/* Filter bar */
.filter-bar {
    background: #fff; border-radius: 12px; padding: 1rem 1.25rem;
    box-shadow: var(--card-shadow); margin-bottom: 1.25rem;
    display: flex; flex-wrap: wrap; gap: .75rem; align-items: end;
}
.filter-bar .form-group { flex: 1; min-width: 150px; }

/* Action buttons in tables */
.table-actions { display: flex; gap: .25rem; }

/* Empty state */
.empty-state { text-align: center; padding: 3rem 1rem; color: #94a3b8; }
.empty-state i { font-size: 3rem; opacity: .4; display: block; margin-bottom: .5rem; }

/* Image upload preview */
.upload-zone { border: 2px dashed #cbd5e1; border-radius: 12px; padding: 2rem; text-align: center; transition: var(--transition); cursor: pointer; }
.upload-zone:hover, .upload-zone.dragover { border-color: var(--primary); background: #eff6ff; }
.upload-zone i { font-size: 2.5rem; color: #94a3b8; }

/* Media grid */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
.media-item { position: relative; border-radius: 8px; overflow: hidden; background: #fff; border: 1px solid #e2e8f0; display: flex; flex-direction: column; }
.media-item .media-thumb { position: relative; aspect-ratio: 4/3; background: #f1f5f9; }
.media-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-item .actions { position: absolute; top: .25rem; right: .25rem; display: flex; gap: .25rem; opacity: 0; transition: opacity .2s; }
.media-item:hover .actions { opacity: 1; }
.media-item .cover-badge { position: absolute; bottom: .25rem; left: .25rem; z-index: 2; }
.media-caption-box { display: flex; gap: .25rem; padding: .4rem; align-items: center; }
.media-caption-box .media-caption { flex: 1; min-width: 0; }

/* Property card in list */
.property-thumb { width: 80px; height: 60px; border-radius: 6px; object-fit: cover; background: #f1f5f9; }

/* Modal */
.modal-content { border: 0; border-radius: 12px; }
.modal-header { border-bottom: 1px solid #e2e8f0; }

/* Alerts */
.alert { border-radius: 8px; border: 0; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    body.sidebar-open .sidebar { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.3); }
    .main-wrapper { margin-left: 0; }
    body.sidebar-open::after {
        content: ''; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1029;
    }
}

@media (max-width: 575.98px) {
    .stat-card { padding: 1rem; }
    .stat-value { font-size: 1.3rem; }
    .content { padding: 1rem; }
    .topbar { padding: 0 1rem; }
}

/* Print */
@media print {
    .sidebar, .topbar, .footer, .no-print { display: none !important; }
    .main-wrapper { margin: 0; }
    .content { padding: 0; }
}
