/* TOPBAR */
.topbar {
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 16px;
    background: var(--topbar-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    width: 72px;
    height: 72px;
    border-radius: 18px;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(var(--tint-rgb), 0.08), rgba(var(--tint-rgb), 0.02));
    padding: 6px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3), inset 0 0 0 1px rgba(var(--tint-rgb), 0.1);
}

.logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.titles h1 {
    font-size: 15px;
    margin: 0;
    font-weight: 700;
    color: var(--text-strong);
}

.titles p {
    margin: 0;
    color: var(--muted);
    font-size: 11px;
}

.top-actions {
    display: flex;
    gap: 8px;
}

/* LAYOUT MAIN */
.layout {
    display: grid;
    grid-template-columns: 420px 1fr;
    width: 100%;
    height: calc(100vh - 82px);
    /* Adjusted for topbar roughly */
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 10px;
    gap: 10px;
}

.panel,
.content {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.content {
    padding: 12px;
}

/* SIDEBAR */
.sidebar {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--sidebar-inset-shadow);
}

.sidebar.collapsed {
    display: none;
}

.sidebar-wrapper {
    padding: 12px 10px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    scrollbar-gutter: stable;
}

.section-group {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    gap: 8px;
    margin-bottom: 12px;
}

/* FORM CONTAINER */
.form-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

#activityForm {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.form-fields {
    flex-shrink: 0;
}

.form-buttons {
    margin-top: auto;
    padding: 16px 14px;
    background: rgba(var(--panel-rgb), 0.9);
    backdrop-filter: blur(10px);
    position: sticky;
    bottom: -15px;
    z-index: 10;
    border-top: 1px solid rgba(var(--tint-rgb), 0.05);
    margin-left: -14px;
    margin-right: -14px;
    box-shadow: var(--form-fade-shadow);
}

/* CONTENT HEAD */
.content-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

/* En el Gantt PME el título/estadísticas del calendario institucional quedan fuera de contexto
   (ya hay un título y selector de año propios del plan justo debajo) — se ocultan. */
body.pme-view .content-head {
    display: none;
}

#viewContainer {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* FOOTER */
.footer {
    padding: 6px 16px;
    color: var(--muted);
    font-size: 10px;
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
}

/* RESPONSIVE */
@media (max-height: 800px) {
    .sidebar-wrapper {
        padding: 12px;
    }

    .section-group {
        margin-bottom: 16px;
    }

    .form-buttons {
        bottom: -12px;
        padding: 12px 14px;
        margin-bottom: 0;
    }
}

@media (max-width: 1000px) {
    .layout {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }

    .panel,
    .content {
        height: auto;
        display: block;
        overflow: visible;
    }

    #viewContainer {
        min-height: 500px;
    }
}

@media (max-width: 640px) {
    .topbar {
        flex-wrap: wrap;
        gap: 8px;
        padding: 8px 10px;
    }

    .logo {
        width: 44px;
        height: 44px;
        border-radius: 12px;
    }

    .titles h1 {
        font-size: 13px;
    }

    .titles p {
        display: none;
    }

    .top-actions {
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 6px;
        width: 100%;
    }

    .layout {
        padding: 6px;
        gap: 6px;
        height: auto;
    }

    body {
        overflow-y: auto;
    }
}

@media print {

    .topbar,
    .sidebar,
    .footer,
    .top-actions,
    .hide-in-pdf,
    .btn,
    .small-btn {
        display: none !important;
    }

    .layout {
        display: block !important;
        padding: 0 !important;
        height: auto !important;
    }

    .content {
        border: none !important;
        box-shadow: none !important;
        background: #fff !important;
        color: #000 !important;
        padding: 0 !important;
    }

    #viewContainer {
        height: auto !important;
        overflow: visible !important;
    }
}



/* Print Infrastructure */
#print-view-container,
#print-only-header {
    display: none;
}