/* ========================================
   APP.CSS - Estilos Principales de Aplicación
   ResidentManagement - Portal Administrativo

   Consolidado: layout + navigation + utilities + responsive
   ======================================== */

/* ========================================
   1. VARIABLES CSS
   ======================================== */
:root {
    --primary-color: #2e7d32;
    --primary-dark: #1b5e20;
    --primary-light: #4caf50;
    --secondary-color: #66bb6a;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --border-color: #dee2e6;
    --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --shadow-md: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);
    --transition-base: all 0.3s ease;
}

/* ========================================
   2. ESTILOS BASE
   ======================================== */
* {
    box-sizing: border-box;
}

html {
    height: 100%;
    font-size: 16px;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-light);
    margin: 0;
    padding: 0;
}

/* === MAIN CONTENT === */
.main-content {
    flex: 1 0 auto;
    padding: 2rem 0;
    min-height: calc(100vh - 200px);
}

.main-content .container {
    background-color: var(--bg-white);
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-sm);
}

/* === FOOTER === */
.footer-main {
    flex-shrink: 0;
    margin-top: auto;
}

/* === TIPOGRAFÍA === */
.portal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
    line-height: 1.2;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; color: var(--primary-color); }
h3 { font-size: 1.5rem; }

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition-base);
}

a:hover {
    color: var(--primary-dark);
}

/* === CARDS === */
.card {
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-base);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background-color: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--primary-color);
}

/* === TABLAS === */
.table {
    color: var(--text-primary);
}

.table thead th {
    background-color: var(--primary-color);
    color: var(--bg-white);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.875rem;
    border: none;
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(46, 125, 50, 0.05);
}

.table-hover tbody tr:hover {
    background-color: rgba(46, 125, 50, 0.1);
    cursor: pointer;
}

/* === BOTONES === */
.btn {
    font-weight: 500;
    border-radius: 0.375rem;
    padding: 0.5rem 1.25rem;
    transition: var(--transition-base);
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-success {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-success:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* === BADGES === */
.badge {
    font-weight: 500;
    padding: 0.35rem 0.75rem;
    border-radius: 0.375rem;
}

.badge.bg-success {
    background-color: var(--primary-color) !important;
}

/* ========================================
   3. NAVEGACIÓN
   ======================================== */
.navbar-header {
    background-color: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    z-index: 1040;
}

.navbar {
    padding: 1rem 0;
}

.navbar-brand {
    display: flex;
    align-items: center;
    padding: 0;
    margin-right: auto;
}

.navbar-logo {
    height: 65px;
    width: auto;
    object-fit: contain;
}

.brand-text {
    margin-left: 1rem;
}

.brand-text .portal-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.3;
}

.badge-subtitle {
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.2rem 0.5rem;
    margin-top: 0.2rem;
    display: inline-block;
}

.navbar-nav {
    align-items: center;
}

.nav-item {
    margin: 0 0.25rem;
}

.nav-link {
    color: var(--text-primary) !important;
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.5rem 1rem !important;
    border-radius: 0.25rem;
    transition: var(--transition-base);
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.nav-link i {
    font-size: 1rem;
}

.nav-link:hover {
    background-color: rgba(46, 125, 50, 0.1);
    color: var(--primary-color) !important;
}

.nav-link.active,
.nav-item.active .nav-link {
    background-color: var(--primary-color);
    color: var(--bg-white) !important;
    font-weight: 600;
}

.dropdown-toggle {
    display: flex;
    align-items: center;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border: none;
    background: none;
    color: var(--text-primary);
}

.dropdown-toggle:hover {
    background-color: rgba(46, 125, 50, 0.1);
    color: var(--primary-color);
}

.dropdown-toggle i {
    font-size: 1.1rem;
}

.dropdown-menu {
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    border-radius: 0.5rem;
    padding: 0.5rem 0;
    margin-top: 0.5rem;
}

.dropdown-item {
    padding: 0.75rem 1.5rem;
    color: var(--text-primary);
    font-weight: 500;
    transition: var(--transition-base);
    display: flex;
    align-items: center;
}

.dropdown-item i {
    width: 20px;
}

.dropdown-item:hover {
    background-color: rgba(46, 125, 50, 0.1);
    color: var(--primary-color);
}

.dropdown-item:active {
    background-color: var(--primary-color);
    color: var(--bg-white);
}

.navbar-toggler {
    border: 2px solid var(--primary-color);
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
}

.navbar-toggler:focus {
    box-shadow: 0 0 0 0.2rem rgba(46, 125, 50, 0.25);
}

.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%232e7d32' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
    width: 1.5rem;
    height: 1.5rem;
}

.sticky-top {
    position: sticky;
    top: 0;
    z-index: 1040;
}

.navbar-collapse.collapsing {
    transition: height 0.3s ease;
}

.navbar-collapse.show {
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.btn-outline-success {
    color: var(--primary-color);
    border-color: var(--primary-color);
    font-weight: 500;
}

.btn-outline-success:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--bg-white);
}

.btn-outline-success:focus {
    box-shadow: 0 0 0 0.2rem rgba(46, 125, 50, 0.25);
}

/* ========================================
   4. UTILIDADES
   ======================================== */

/* Spacing */
.mt-6 { margin-top: 4rem !important; }
.mb-6 { margin-bottom: 4rem !important; }
.py-6 { padding-top: 4rem !important; padding-bottom: 4rem !important; }
.px-6 { padding-left: 4rem !important; padding-right: 4rem !important; }

/* Text */
.text-premium { color: var(--primary-color) !important; font-weight: 600; }
.text-muted-custom { color: var(--text-muted) !important; }
.text-uppercase { text-transform: uppercase !important; letter-spacing: 0.5px; }
.text-bold { font-weight: 700 !important; }
.text-semi-bold { font-weight: 600 !important; }
.text-small { font-size: 0.875rem !important; }
.text-large { font-size: 1.125rem !important; }

/* Background */
.bg-light-custom { background-color: var(--bg-light) !important; }
.bg-premium { background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%) !important; color: var(--bg-white) !important; }
.bg-gradient-primary { background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%) !important; }

/* Borders */
.border-premium { border-color: var(--primary-color) !important; }
.border-thick { border-width: 2px !important; }
.border-radius-lg { border-radius: 0.75rem !important; }
.border-radius-xl { border-radius: 1rem !important; }

/* Shadows */
.shadow-premium { box-shadow: var(--shadow-md) !important; }
.shadow-premium-lg { box-shadow: var(--shadow-lg) !important; }
.shadow-none { box-shadow: none !important; }
.hover-shadow { transition: var(--transition-base); }
.hover-shadow:hover { box-shadow: var(--shadow-md) !important; }

/* Display */
.d-flex-center { display: flex !important; justify-content: center !important; align-items: center !important; }
.d-flex-between { display: flex !important; justify-content: space-between !important; align-items: center !important; }

/* Width / Height */
.w-fit { width: fit-content !important; }
.h-fit { height: fit-content !important; }
.min-h-100 { min-height: 100px !important; }
.min-h-200 { min-height: 200px !important; }
.min-h-300 { min-height: 300px !important; }

/* Cursor */
.cursor-pointer { cursor: pointer !important; }
.cursor-not-allowed { cursor: not-allowed !important; }

/* Transitions */
.transition-base { transition: var(--transition-base) !important; }
.transition-fast { transition: all 0.15s ease !important; }
.transition-slow { transition: all 0.5s ease !important; }

/* Hover Effects */
.hover-lift { transition: var(--transition-base); }
.hover-lift:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.hover-scale { transition: var(--transition-base); }
.hover-scale:hover { transform: scale(1.05); }
.hover-opacity { transition: var(--transition-base); }
.hover-opacity:hover { opacity: 0.8; }

/* Overflow */
.overflow-hidden { overflow: hidden !important; }
.overflow-x-auto { overflow-x: auto !important; }
.overflow-y-auto { overflow-y: auto !important; }

/* Position */
.position-center { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }

/* Z-index */
.z-index-high { z-index: 1000 !important; }
.z-index-modal { z-index: 1050 !important; }
.z-index-toast { z-index: 1055 !important; }

/* Divider */
.divider { height: 1px; background-color: var(--border-color); margin: 1.5rem 0; }
.divider-thick { height: 2px; background-color: var(--primary-color); margin: 2rem 0; }

/* Links */
.link-premium { color: var(--primary-color); text-decoration: none; font-weight: 600; transition: var(--transition-base); }
.link-premium:hover { color: var(--primary-dark); text-decoration: underline; }

/* Icons */
.icon-sm { font-size: 0.875rem; }
.icon-md { font-size: 1.25rem; }
.icon-lg { font-size: 1.75rem; }
.icon-xl { font-size: 2.5rem; }

/* Opacity */
.opacity-50 { opacity: 0.5 !important; }
.opacity-75 { opacity: 0.75 !important; }
.opacity-90 { opacity: 0.9 !important; }

/* ========================================
   5. RESPONSIVE (Mobile-First)
   ======================================== */

/* Extra Small Devices (<576px) */
@media (max-width: 575.98px) {
    .main-content { padding: 1rem 0; }
    .main-content .container { padding: 1rem; border-radius: 0; }
    .navbar-logo { height: 50px; }
    .brand-text .portal-title { font-size: 1rem; }
    .badge-subtitle { font-size: 0.65rem; }
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.35rem; }
    h3 { font-size: 1.15rem; }
    .table { font-size: 0.875rem; }
    .table thead th { font-size: 0.75rem; padding: 0.5rem 0.25rem; }
    .table tbody td { padding: 0.5rem 0.25rem; }
    .table-responsive { border-radius: 0.5rem; box-shadow: var(--shadow-sm); }
    .card { margin-bottom: 1rem; }
    .card-body { padding: 1rem; }
    .btn { padding: 0.5rem 1rem; font-size: 0.875rem; }
    .btn-group { display: flex; flex-direction: column; gap: 0.5rem; }
    .btn-group .btn { width: 100%; }
    .form-control, .form-select { font-size: 0.875rem; }
    .mt-4, .my-4 { margin-top: 1.5rem !important; }
    .mb-4, .my-4 { margin-bottom: 1.5rem !important; }
    .navbar-collapse { background-color: var(--bg-white); padding: 1rem; margin-top: 1rem; border-radius: 0.5rem; box-shadow: var(--shadow-md); border: 1px solid var(--border-color); }
    .navbar-nav { flex-direction: column; align-items: stretch; width: 100%; }
    .nav-item { margin: 0.25rem 0; width: 100%; }
    .nav-link { width: 100%; padding: 0.75rem 1rem !important; }
    .navbar-brand { margin-right: 0; flex: 1; }
    .brand-text { margin-left: 0.75rem; }
    .dropdown-menu { position: static !important; transform: none !important; box-shadow: none; border: none; padding-left: 1rem; margin-top: 0.5rem; width: 100%; }
}

/* Small Devices (≥576px and <768px) */
@media (min-width: 576px) and (max-width: 767.98px) {
    .navbar-logo { height: 55px; }
    .brand-text .portal-title { font-size: 1.2rem; }
}

/* Medium Devices (≥768px and <992px) */
@media (min-width: 768px) and (max-width: 991.98px) {
    .navbar-logo { height: 60px; }
    .brand-text .portal-title { font-size: 1.3rem; }
    .main-content .container { padding: 1.5rem; }
    .table { font-size: 0.9rem; }
    .card-body { padding: 1.25rem; }
    .navbar-collapse { background-color: var(--bg-white); padding: 1rem; margin-top: 1rem; border-radius: 0.5rem; box-shadow: var(--shadow-md); border: 1px solid var(--border-color); }
    .navbar-nav { flex-direction: column; align-items: stretch; width: 100%; }
    .nav-item { margin: 0.25rem 0; width: 100%; }
    .nav-link { width: 100%; padding: 0.75rem 1rem !important; }
    .dropdown-menu { position: static !important; transform: none !important; box-shadow: none; border: none; padding-left: 1rem; margin-top: 0.5rem; width: 100%; }
}

/* Large Devices (≥992px and <1200px) */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .navbar-logo { height: 60px; }
    .container { max-width: 960px; }
}

/* Extra Large Devices (≥1200px) */
@media (min-width: 1200px) {
    .navbar-logo { height: 65px; }
    .container { max-width: 1140px; }
    .main-content .container { padding: 2.5rem; }
}

/* Landscape (Mobile) */
@media (max-width: 767.98px) and (orientation: landscape) {
    .main-content { padding: 0.75rem 0; }
    .navbar { padding: 0.5rem 0; }
}

/* Responsive Utilities */
@media (max-width: 991.98px) {
    .hide-mobile { display: none !important; }
    .show-mobile { display: block !important; }
    .py-mobile-2 { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
    .px-mobile-2 { padding-left: 0.5rem !important; padding-right: 0.5rem !important; }
    .flex-mobile-column { flex-direction: column !important; }
    .flex-mobile-column > * { width: 100% !important; margin-bottom: 0.5rem; }
}

@media (min-width: 992px) {
    .hide-desktop { display: none !important; }
    .show-desktop { display: block !important; }
    .text-responsive { font-size: 0.875rem !important; }
    .h1.text-responsive, h1.text-responsive { font-size: 1.75rem !important; }
    .h2.text-responsive, h2.text-responsive { font-size: 1.5rem !important; }
}

/* Print Styles */
@media print {
    .navbar-header, .footer-main, .environment-badge, .btn, .dropdown { display: none !important; }
    .main-content { padding: 0; }
    .main-content .container { box-shadow: none; border-radius: 0; }
    body { background-color: white; }
    .table { page-break-inside: auto; }
    .table tr { page-break-inside: avoid; page-break-after: auto; }
}

/* Reduced Motion (Accessibility) */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High Contrast (Accessibility) */
@media (prefers-contrast: high) {
    .card { border: 2px solid var(--text-primary); }
    .btn { border: 2px solid currentColor; }
    .nav-link { border-bottom: 2px solid transparent; }
    .nav-link:hover, .nav-link.active { border-bottom-color: currentColor; }
}
