/* ============================================
   Domus - Administracion de Consorcios
   Paleta: Esmeralda / Roble / Acero / Pizarra
   ============================================ */

:root {
    /* Primary - Esmeralda (naturaleza, hogar) */
    --dm-primary: #2D8B5E;
    --dm-primary-hover: #359E6B;
    --dm-primary-light: rgba(45, 139, 94, 0.12);
    --dm-primary-border: rgba(45, 139, 94, 0.25);

    /* Secondary - Roble (calidez, madera) */
    --dm-secondary: #8B6F47;
    --dm-secondary-hover: #9E7F54;
    --dm-secondary-light: rgba(139, 111, 71, 0.12);

    /* Accent - Acero/Cielo (informacion) */
    --dm-accent: #4A90B8;
    --dm-accent-hover: #5BA0C8;
    --dm-accent-light: rgba(74, 144, 184, 0.12);

    /* Dark - Pizarra (textos, sidebar) */
    --dm-dark-1: #1E293B;
    --dm-dark-2: #253347;
    --dm-dark-3: #334155;

    /* Surfaces */
    --dm-bg-content: #FAFAFA;
    --dm-bg-card: #FFFFFF;
    --dm-text-light: #E8EAF0;
    --dm-text-muted: #94A3B8;
    --dm-border: #E2E8F0;
    --dm-border-subtle: rgba(45, 139, 94, 0.2);

    /* Feedback */
    --dm-success: #22C55E;
    --dm-warning: #F59E0B;
    --dm-danger: #EF4444;
    --dm-info: #4A90B8;
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    margin: 0;
    padding: 0;
    background: var(--dm-bg-content);
    color: var(--dm-dark-1);
    font-size: 14px;
}

a { color: var(--dm-primary); text-decoration: none; }
a:hover { color: var(--dm-primary-hover); }

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

/* Sidebar */
.sidebar {
    width: 260px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    background: linear-gradient(180deg, var(--dm-dark-1) 0%, var(--dm-dark-2) 60%, var(--dm-dark-2) 100%);
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.3s ease;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--dm-dark-3); border-radius: 4px; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid var(--dm-primary-border);
}

.sidebar-brand-icon {
    font-size: 1.75rem;
    color: var(--dm-primary);
}

.sidebar-brand-text {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--dm-primary);
    letter-spacing: 1.5px;
}

.sidebar-section-title {
    padding: 1rem 1.25rem 0.4rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--dm-primary);
    opacity: 0.7;
    font-weight: 600;
}

/* Sidebar links */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.25rem;
    color: rgba(232, 234, 240, 0.7);
    font-size: 0.875rem;
    border-left: 3px solid transparent;
    transition: all 0.15s ease;
    cursor: pointer;
    text-decoration: none;
}

.sidebar-link:hover {
    color: var(--dm-text-light);
    background: var(--dm-primary-light);
    text-decoration: none;
}

.sidebar-link.active {
    color: var(--dm-primary);
    border-left-color: var(--dm-primary);
    background: var(--dm-primary-light);
    font-weight: 600;
}

.sidebar-link .icon {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    opacity: 0.85;
}

/* Sidebar group (collapsible) */
.sidebar-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.6rem 1.25rem;
    background: none;
    border: none;
    color: rgba(232, 234, 240, 0.7);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.sidebar-group-toggle:hover {
    color: var(--dm-text-light);
    background: var(--dm-primary-light);
}

.sidebar-group-toggle .chevron {
    transition: transform 0.25s ease;
    font-size: 0.7rem;
}

.sidebar-group-toggle.open .chevron {
    transform: rotate(180deg);
}

.sidebar-group-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}

.sidebar-group-items.open {
    max-height: 500px;
}

.sidebar-group-items .sidebar-link {
    padding-left: 2.75rem;
    font-size: 0.825rem;
}

/* Main content */
.main-content {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Topbar */
.top-bar {
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    background: var(--dm-dark-2);
    border-bottom: 1px solid var(--dm-primary-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--dm-text-light);
    font-weight: 600;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.top-bar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--dm-text-light);
    font-size: 0.875rem;
    cursor: pointer;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    transition: background 0.15s ease;
}

.top-bar-user:hover {
    background: rgba(255,255,255,0.08);
}

/* Page content */
.page-content {
    flex: 1;
    padding: 1.5rem;
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--dm-bg-card);
    border: 1px solid var(--dm-border);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: var(--dm-dark-1);
    color: var(--dm-text-light);
    border-bottom: 2px solid var(--dm-primary);
    border-radius: 8px 8px 0 0;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--dm-primary);
    color: white;
}
.btn-primary:hover { background: var(--dm-primary-hover); color: white; }

.btn-secondary {
    background: var(--dm-secondary);
    color: white;
}
.btn-secondary:hover { background: var(--dm-secondary-hover); color: white; }

.btn-accent {
    background: var(--dm-accent);
    color: white;
}
.btn-accent:hover { background: var(--dm-accent-hover); color: white; }

.btn-danger {
    background: var(--dm-danger);
    color: white;
}
.btn-danger:hover { background: #DC2626; color: white; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--dm-border);
    color: var(--dm-dark-1);
}
.btn-outline:hover { background: var(--dm-bg-content); }

.btn-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
}

/* ============================================
   FORMS
   ============================================ */
.form-label {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.825rem;
    font-weight: 600;
    color: var(--dm-dark-3);
}

.form-control, .form-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #c8cdd3;
    border-radius: 6px;
    font-size: 0.875rem;
    background: white;
    color: var(--dm-dark-1);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--dm-primary);
    box-shadow: 0 0 0 3px var(--dm-primary-light);
}

.form-control.invalid {
    border-color: var(--dm-danger);
}

.form-group {
    margin-bottom: 1rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

/* ============================================
   TABLES
   ============================================ */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table thead th {
    padding: 0.65rem 0.75rem;
    background: var(--dm-dark-1);
    color: var(--dm-text-light);
    font-size: 0.8rem;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
}

table tbody td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--dm-border);
    font-size: 0.85rem;
}

table tbody tr:hover {
    background: var(--dm-primary-light);
}

/* ============================================
   BADGES
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: rgba(34,197,94,0.15); color: #16A34A; }
.badge-warning { background: rgba(245,158,11,0.15); color: #D97706; }
.badge-danger { background: rgba(239,68,68,0.15); color: #DC2626; }
.badge-info { background: var(--dm-accent-light); color: var(--dm-accent); }
.badge-secondary { background: var(--dm-secondary-light); color: var(--dm-secondary); }

/* ============================================
   ALERTS
   ============================================ */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.alert-danger { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #DC2626; }
.alert-success { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); color: #16A34A; }
.alert-info { background: var(--dm-accent-light); border: 1px solid rgba(74,144,184,0.3); color: var(--dm-accent); }

/* ============================================
   PAGE HEADER
   ============================================ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dm-dark-1);
    margin: 0;
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #0F1A2E 0%, var(--dm-dark-1) 100%);
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--dm-dark-2);
    border: 1px solid var(--dm-primary-border);
    border-radius: 12px;
    padding: 2.5rem 2rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.login-brand {
    text-align: center;
    margin-bottom: 2rem;
}

.login-brand-icon {
    font-size: 3rem;
    color: var(--dm-primary);
    margin-bottom: 0.5rem;
}

.login-brand-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--dm-primary);
    letter-spacing: 2px;
}

.login-brand-subtitle {
    font-size: 0.85rem;
    color: var(--dm-text-muted);
    margin-top: 0.25rem;
}

.login-card .form-control {
    background: rgba(255,255,255,0.06);
    border-color: var(--dm-dark-3);
    color: var(--dm-text-light);
}

.login-card .form-control:focus {
    border-color: var(--dm-primary);
    background: rgba(255,255,255,0.08);
}

.login-card .form-control::placeholder {
    color: var(--dm-text-muted);
}

.login-card .form-label {
    color: var(--dm-text-muted);
}

.login-btn {
    width: 100%;
    padding: 0.7rem;
    background: var(--dm-primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.login-btn:hover { background: var(--dm-primary-hover); }
.login-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.75rem;
    color: var(--dm-text-muted);
}

/* ============================================
   RESPONSIVE
   ============================================ */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--dm-text-light);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .sidebar-toggle {
        display: block;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   UTILITIES
   ============================================ */
.text-muted { color: var(--dm-text-muted); }
.text-primary { color: var(--dm-primary); }
.text-danger { color: var(--dm-danger); }
.text-success { color: var(--dm-success); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.d-flex { display: flex; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ============================================
   PORTAL DEL HABITANTE
   ============================================ */
.portal-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--dm-bg-content);
}

/* Header */
.portal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    height: 60px;
    background: var(--dm-dark-1);
    color: var(--dm-text-light);
    position: sticky;
    top: 0;
    z-index: 100;
}

.portal-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--dm-text-light);
    text-decoration: none;
    font-weight: 700;
}
.portal-brand-icon { font-size: 1.4rem; }
.portal-brand-text { font-size: 1.1rem; letter-spacing: 2px; }

.portal-nav {
    display: flex;
    gap: 0.25rem;
}
.portal-nav-link {
    color: var(--dm-text-muted);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    text-decoration: none;
    transition: all 0.2s;
}
.portal-nav-link:hover {
    color: var(--dm-text-light);
    background: rgba(255,255,255,0.08);
}
.portal-nav-link.active {
    color: var(--dm-primary);
    background: var(--dm-primary-light);
}

.portal-header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
}

.portal-user {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--dm-text-muted);
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
}
.portal-user:hover { color: var(--dm-text-light); background: rgba(255,255,255,0.06); }

.portal-user-menu {
    position: absolute;
    top: 45px;
    right: 0;
    background: var(--dm-dark-2);
    border: 1px solid var(--dm-primary-border);
    border-radius: 8px;
    min-width: 180px;
    z-index: 200;
    padding: 0.25rem 0;
}
.portal-user-menu-item {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--dm-text-light);
    font-size: 0.85rem;
    text-decoration: none;
}
.portal-user-menu-item:hover {
    background: rgba(255,255,255,0.06);
    color: var(--dm-text-light);
}

.portal-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--dm-text-light);
    font-size: 1.3rem;
    cursor: pointer;
}

/* Content */
.portal-content {
    flex: 1;
    padding: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Footer */
.portal-footer {
    text-align: center;
    padding: 1rem;
    font-size: 0.8rem;
    color: var(--dm-text-muted);
    border-top: 1px solid var(--dm-border);
}

/* Portal cards grid */
.portal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.portal-stat-card {
    background: var(--dm-bg-card);
    border: 1px solid var(--dm-border);
    border-radius: 10px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: box-shadow 0.2s;
}
.portal-stat-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }

.portal-stat-icon {
    font-size: 2rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}
.portal-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dm-dark-1);
}
.portal-stat-label {
    font-size: 0.8rem;
    color: var(--dm-text-muted);
}

/* Portal Login */
.portal-login-container {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--dm-dark-1), var(--dm-dark-2));
}
.portal-login-card {
    width: 400px;
    background: var(--dm-bg-card);
    border-radius: 12px;
    padding: 2.5rem 2rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.portal-login-brand {
    text-align: center;
    margin-bottom: 2rem;
}
.portal-login-brand-icon { font-size: 3rem; }
.portal-login-brand-title { font-size: 1.6rem; font-weight: 800; letter-spacing: 3px; color: var(--dm-primary); }
.portal-login-brand-subtitle { font-size: 0.85rem; color: var(--dm-text-muted); margin-top: 0.25rem; }

.portal-login-btn {
    width: 100%;
    padding: 0.75rem;
    background: var(--dm-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 0.5rem;
}
.portal-login-btn:hover { background: var(--dm-primary-hover); }

.portal-login-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.75rem;
    color: var(--dm-text-muted);
}

/* Empty state */
.portal-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--dm-text-muted);
}
.portal-empty-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.portal-empty-text { font-size: 0.9rem; }

/* Responsive portal */
@media (max-width: 768px) {
    .portal-nav { display: none; flex-direction: column; position: absolute; top: 60px; left: 0; right: 0; background: var(--dm-dark-1); padding: 0.5rem; }
    .portal-nav.open { display: flex; }
    .portal-menu-toggle { display: block; }
    .portal-content { padding: 1rem; }
    .portal-grid { grid-template-columns: 1fr; }
}
