/* ===== VIVIENDA GESTION - Custom CSS ===== */
:root {
    --sidebar-bg: #1a2744;
    --sidebar-hover: #243460;
    --sidebar-active: #2e4080;
    --sidebar-text: #c8d3f0;
    --sidebar-muted: #6b7db3;
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --primary: #2563eb;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --card-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

* {
    box-sizing: border-box;
}

html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

img, canvas, svg, video {
    max-width: 100%;
}

/* ===== LOGIN PAGE ===== */
.login-page {
    background: linear-gradient(135deg, #1a2744 0%, #243460 50%, #1e3a8a 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, #1a2744, #2e4080);
    padding: 36px 32px 28px;
    text-align: center;
    color: white;
}

.login-logo {
    width: 72px;
    height: 72px;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 32px;
}

.login-company {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 2px;
    margin: 0;
}

.login-subtitle {
    font-size: 11px;
    letter-spacing: 3px;
    color: rgba(255,255,255,0.7);
    margin: 4px 0 8px;
    text-transform: uppercase;
}

.login-address {
    color: rgba(255,255,255,0.5) !important;
}

.login-body {
    padding: 32px;
}

.login-footer {
    background: #f8f9fa;
    padding: 12px 32px;
    text-align: center;
    border-top: 1px solid #e9ecef;
}

/* ===== SIDEBAR ===== */
#wrapper {
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    overflow-y: hidden;
    overflow-x: hidden;
}

.sidebar-header {
    padding: 12px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: rgba(0,0,0,0.15);
    flex: 0 0 auto;
}

.company-logo-img img {
    width: 48px !important;
    height: 48px !important;
}

.company-logo {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    flex-shrink: 0;
}

.company-name {
    font-size: 15px;
    font-weight: 800;
    color: white;
    letter-spacing: 1px;
    line-height: 1.2;
}

.company-sub {
    font-size: 10px;
    color: var(--sidebar-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.sidebar-menu {
    padding: 8px 0 20px;
    flex: 1;
    margin: 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.45) transparent;
}

.sidebar-section-title {
    padding: 10px 16px 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--sidebar-muted);
    text-transform: uppercase;
}

.sidebar-item {
    margin: 1px 6px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: white;
}

.sidebar-link i {
    font-size: 15px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-item.active .sidebar-link {
    background: var(--sidebar-active);
    color: white;
    box-shadow: 0 2px 8px rgba(46, 64, 128, 0.4);
}

/* ===== TOP NAVBAR ===== */
#page-content-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin 0.3s ease;
    min-width: 0;
}

.top-navbar {
    height: var(--topbar-height);
    background: white;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 999;
}

.sidebar-toggle {
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    color: #6b7280;
    font-size: 18px;
    padding: 4px 8px;
}

.sidebar-toggle:hover {
    background: #f3f4f6;
    color: #1a2744;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 6px;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    padding: 24px;
    flex: 1;
    background: #f4f6fb;
    min-width: 0;
}

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: #1a2744;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-title i {
    color: var(--primary);
}

/* ===== CARDS ===== */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
}

.card-header {
    background: white;
    border-bottom: 1px solid #f0f2f7;
    border-radius: 12px 12px 0 0 !important;
    padding: 16px 20px;
    font-weight: 600;
    color: #1a2744;
}

/* ===== STAT CARDS ===== */
.stat-card {
    background: white;
    border-radius: 14px;
    padding: 20px 24px;
    box-shadow: var(--card-shadow);
    border: none;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.stat-card.blue::before { background: #2563eb; }
.stat-card.green::before { background: #16a34a; }
.stat-card.red::before { background: #dc2626; }
.stat-card.orange::before { background: #d97706; }
.stat-card.purple::before { background: #7c3aed; }

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 12px;
}

.stat-icon.blue { background: #eff6ff; color: #2563eb; }
.stat-icon.green { background: #f0fdf4; color: #16a34a; }
.stat-icon.red { background: #fef2f2; color: #dc2626; }
.stat-icon.orange { background: #fffbeb; color: #d97706; }
.stat-icon.purple { background: #f5f3ff; color: #7c3aed; }

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: #1a2744;
    line-height: 1.2;
}

.stat-label {
    font-size: 13px;
    color: #6b7280;
    margin-top: 2px;
}

/* ===== TABLES ===== */
.table-card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-card-header {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f0f2f7;
}

.table-card-title {
    font-size: 16px;
    font-weight: 600;
    color: #1a2744;
    margin: 0;
}

.table thead th {
    background: #f8faff;
    color: #374151;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 16px;
    border-bottom: 2px solid #e5e7eb;
    border-top: none;
    white-space: nowrap;
}

.table tbody td {
    padding: 12px 16px;
    font-size: 13.5px;
    color: #374151;
    vertical-align: middle;
    border-bottom: 1px solid #f3f4f6;
}

.table tbody tr:hover {
    background: #f8faff;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* ===== BADGES ===== */
.badge {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 600;
}

/* ===== FORMS ===== */
.form-card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    padding: 28px 32px;
    max-width: 800px;
    width: 100%;
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.form-control, .form-select {
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    padding: 9px 12px;
    transition: all 0.2s;
}

.form-control:focus, .form-select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ===== BUTTONS ===== */
.btn {
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 500;
    padding: 8px 16px;
}

.btn-primary {
    background: #2563eb;
    border-color: #2563eb;
}

.btn-primary:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-action {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    padding: 0;
    font-size: 13px;
}

/* ===== ACCOUNT CARDS ===== */
.account-card {
    background: white;
    border-radius: 14px;
    padding: 20px;
    box-shadow: var(--card-shadow);
    border-top: 4px solid #2563eb;
}

.account-card.cash {
    border-top-color: #16a34a;
}

.account-balance {
    font-size: 24px;
    font-weight: 700;
    color: #1a2744;
}

.account-balance.negative {
    color: #dc2626;
}

/* ===== INVOICE LINES ===== */
.invoice-lines-table th {
    background: #f8faff;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    padding: 10px 12px;
}

.invoice-lines-table td {
    padding: 8px 12px;
    vertical-align: middle;
}

.invoice-totals {
    background: #f8faff;
    border-radius: 10px;
    padding: 16px 20px;
}

/* ===== MESSAGES ===== */
.messages-container {
    margin-bottom: 16px;
}

.alert {
    border-radius: 10px;
    font-size: 14px;
    border: none;
}

.alert-success { background: #f0fdf4; color: #166534; border-left: 4px solid #16a34a; }
.alert-danger { background: #fef2f2; color: #991b1b; border-left: 4px solid #dc2626; }
.alert-warning { background: #fffbeb; color: #92400e; border-left: 4px solid #d97706; }
.alert-info { background: #eff6ff; color: #1e40af; border-left: 4px solid #2563eb; }

/* ===== COLLAPSED SIDEBAR ===== */
.sidebar.collapsed {
    width: 64px;
}

.sidebar.collapsed .company-info,
.sidebar.collapsed .sidebar-link span,
.sidebar.collapsed .sidebar-section-title {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
}

.sidebar.collapsed + #page-content-wrapper {
    margin-left: 64px;
}

/* ===== COLOR SWATCH ===== */
.color-swatch {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 4px;
    vertical-align: middle;
    border: 1px solid rgba(0,0,0,0.1);
}

/* ===== CHART CONTAINERS ===== */
.chart-container {
    position: relative;
    height: 280px;
    min-height: 220px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
    :root {
        --sidebar-width: 240px;
    }
    .main-content {
        padding: 20px;
    }
    .stat-card {
        padding: 16px;
    }
    .stat-value {
        font-size: 20px;
    }
    .table thead th,
    .table tbody td {
        padding: 10px 12px;
    }
}

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        width: min(82vw, 300px);
        height: 100vh;
        height: 100dvh;
        box-shadow: 18px 0 40px rgba(15, 23, 42, 0.25);
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    .sidebar.collapsed {
        width: min(82vw, 300px);
    }
    .sidebar.collapsed .company-info,
    .sidebar.collapsed .sidebar-link span,
    .sidebar.collapsed .sidebar-section-title {
        display: block;
    }
    #page-content-wrapper,
    .sidebar.collapsed + #page-content-wrapper {
        margin-left: 0 !important;
        width: 100%;
    }
    .top-navbar {
        height: auto;
        min-height: var(--topbar-height);
        padding: 8px 12px;
    }
    .main-content {
        padding: 16px;
    }
    .page-header {
        align-items: flex-start;
    }
    .page-title {
        font-size: 20px;
    }
    .top-navbar .container-fluid {
        gap: 10px;
    }
    .user-info {
        min-width: 0;
    }
    .user-name {
        max-width: 34vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .table {
        min-width: 760px;
    }
    .chart-container {
        height: 260px;
    }
}

@media (max-width: 576px) {
    .sidebar {
        width: min(88vw, 320px);
    }
    .sidebar-header {
        padding: 10px;
    }
    .company-logo-img img {
        width: 44px !important;
        height: 44px !important;
    }
    .company-name {
        font-size: 14px;
    }
    .company-sub {
        font-size: 9px;
    }
    .sidebar-menu {
        padding: 6px 0 28px;
    }
    .sidebar-section-title {
        padding: 8px 14px 3px;
    }
    .sidebar-link {
        padding: 8px 10px;
        font-size: 13px;
    }
    .main-content {
        padding: 12px;
    }
    .page-header {
        display: block;
    }
    .page-header .btn,
    .page-header a.btn {
        width: 100%;
        margin-top: 10px;
    }
    .page-title {
        font-size: 18px;
        line-height: 1.25;
    }
    .top-navbar .ms-auto {
        gap: 8px !important;
    }
    .user-name,
    .top-navbar .badge {
        display: none;
    }
    .top-navbar a.btn {
        width: 36px;
        height: 36px;
        padding: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 0;
    }
    .top-navbar a.btn i {
        margin: 0 !important;
        font-size: 16px;
    }
    .card-header,
    .table-card-header {
        padding: 12px 14px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .card-body {
        padding: 14px;
    }
    .stat-card {
        padding: 14px 16px;
        border-radius: 10px;
    }
    .stat-value {
        font-size: 18px;
    }
    .stat-label {
        font-size: 12px;
    }
    .form-card {
        padding: 16px 12px;
        border-radius: 10px;
    }
    .row {
        --bs-gutter-x: .75rem;
    }
    .btn {
        padding: 7px 12px;
    }
    .btn-action {
        width: 34px;
        height: 34px;
    }
    .table {
        min-width: 680px;
    }
    .table thead th,
    .table tbody td {
        padding: 9px 10px;
        font-size: 12px;
    }
    .chart-container {
        height: 240px;
    }
    .login-wrapper,
    .login-container {
        max-width: 100%;
        padding: 12px;
    }
    .login-body {
        padding: 22px 18px;
    }
    .login-company {
        font-size: 18px;
    }
}

/* ===== CONFIRM DELETE ===== */
.delete-card {
    background: white;
    border-radius: 14px;
    box-shadow: var(--card-shadow);
    padding: 40px;
    max-width: 480px;
    text-align: center;
}

.delete-icon {
    width: 72px;
    height: 72px;
    background: #fef2f2;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 32px;
    color: #dc2626;
}

/* ===== TABS ===== */
.nav-tabs .nav-link {
    color: #6b7280;
    border: none;
    padding: 10px 20px;
    font-weight: 500;
    font-size: 14px;
    border-radius: 8px 8px 0 0;
}

.nav-tabs .nav-link.active {
    background: white;
    color: #2563eb;
    border-bottom: 3px solid #2563eb;
    font-weight: 600;
}

/* ===== SCROLLBAR ===== */
.sidebar-menu::-webkit-scrollbar {
    width: 8px;
}
.sidebar-menu::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.35);
    border-radius: 999px;
}
.sidebar-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.55);
}
