/* Sidebar Layout for Sistema de Construcción */

/* Main layout structure */
body {
    overflow-x: hidden;
}

/* Sidebar positioning */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: 280px;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Main content positioning */
.main-content {
    margin-left: 280px;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
    position: relative;
}

/* Top navigation positioning */
.top-nav {
    position: sticky;
    top: 0;
    z-index: 999;
    background: white;
    border-bottom: 1px solid #e9ecef;
}

/* Page content positioning */
.page-content {
    padding: 20px;
    min-height: calc(100vh - 70px);
}

/* Sidebar toggle functionality */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    color: #6c757d;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.sidebar-toggle:hover {
    background-color: #f8f9fa;
    color: #495057;
}

/* Sidebar collapsed state */
.sidebar.collapsed {
    width: 70px;
    overflow: hidden;
}

.sidebar.collapsed .sidebar-logo .logo-text,
.sidebar.collapsed .nav-link span {
    display: none;
}

.sidebar.collapsed .nav-link {
    text-align: center;
    padding: 15px 10px;
}

.sidebar.collapsed .nav-link i {
    font-size: 18px;
    margin: 0;
}

/* Main content when sidebar collapsed */
.main-content.sidebar-collapsed {
    margin-left: 70px;
}

/* Responsive sidebar behavior */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    
    .sidebar-toggle {
        display: block;
    }
    
    /* Overlay when sidebar is open on mobile */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
}

/* Sidebar scrollbar styling */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Sidebar header positioning */
.sidebar-header {
    position: sticky;
    top: 0;
    background: inherit;
    z-index: 10;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Sidebar footer positioning */
.sidebar-footer {
    position: sticky;
    bottom: 0;
    background: inherit;
    z-index: 10;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 15px 20px;
}

/* Logo positioning within sidebar */
.sidebar-logo {
    position: relative;
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-text {
    flex: 1;
    min-width: 0;
}

/* Navigation positioning */
.nav-list {
    padding: 20px 0;
    margin: 0;
    list-style: none;
}

.nav-item {
    margin: 0;
    padding: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    border-left-color: #007bff;
}

.nav-link.active {
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
    border-left-color: #007bff;
}

.nav-link i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.nav-link span {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Submenu positioning */
.nav-item.has-submenu {
    position: relative;
}

.submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: rgba(0, 0, 0, 0.1);
}

.submenu.active {
    max-height: 500px;
}

.submenu .nav-link {
    padding-left: 55px;
    font-size: 14px;
}

/* Sidebar toggle button positioning */
.sidebar-toggle-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.sidebar-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Sidebar animation states */
.sidebar {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.animating {
    pointer-events: none;
}

/* Print styles */
@media print {
    .sidebar {
        display: none;
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
    }
}
