/* vistas.css - Estructura de vistas, layouts y paneles principales */

/* Layout Principal */
#app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
aside {
    width: 260px;
    background-color: rgba(24, 24, 27, 0.85);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: all 0.3s ease;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 3rem;
}

.brand {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.brand:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.5) !important;
    background-color: rgba(255, 255, 255, 0.9) !important;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25) !important;
}

.sidebar-logo-bottom {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.sidebar-logo-bottom:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(79, 70, 229, 0.4);
}

.brand-icon svg {
    width: 22px;
    height: 22px;
    fill: #ffffff;
}

.brand h1 {
    font-size: 1.4rem;
    font-weight: 700;
    background: linear-gradient(to right, var(--text-main), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1.25rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    font-size: 0.95rem;
}

.nav-item:hover, .nav-item.active {
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(194, 94, 67, 0.15) 0%, rgba(194, 94, 67, 0) 100%);
    border-left: 3px solid var(--primary);
    padding-left: calc(1.25rem - 3px);
}

.nav-item svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    transition: transform 0.2s ease;
}

.nav-item:hover svg {
    transform: translateX(2px);
}

/* User Info Panel in Sidebar */
.user-panel {
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #ffffff;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: capitalize;
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font-app);
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.btn-logout:hover {
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.4);
    background-color: var(--danger-bg);
}

/* Main Area */
main {
    flex-grow: 1;
    margin-left: 260px;
    padding: 1.5rem 2rem;
    min-height: 100vh;
}

/* Secciones */
.app-section {
    display: none;
    animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.app-section.active {
    display: block;
}

/* Dashboard Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.chart-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

/* Custom CSS Bar Chart */
.bar-chart-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.bar-row {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.bar-label-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
}

.bar-name {
    font-weight: 500;
}

.bar-value {
    color: var(--text-muted);
}

.bar-track {
    height: 10px;
    background-color: var(--bg-input);
    border-radius: 5px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: 5px;
    transition: width 1s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Top Rooms list */
.room-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.room-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
}

.room-name {
    font-weight: 500;
    font-size: 0.9rem;
}

.room-count {
    background-color: var(--primary);
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
}

/* Login Panel Layout */
#login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-app);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    padding: 1.5rem;
}

.login-card {
    background-color: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-main);
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    box-shadow: var(--shadow-main);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.login-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.login-logo {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
    box-shadow: 0 4px 20px rgba(194, 94, 67, 0.4);
}

.login-logo svg {
    width: 28px;
    height: 28px;
    fill: #ffffff;
}

.login-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.login-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

#login-error-msg {
    color: var(--danger);
    background-color: var(--danger-bg);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    display: none;
    text-align: center;
}

/* Kanban / Columns for Tareas (Trabajos) */
.tasks-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .tasks-columns {
        grid-template-columns: 1fr;
    }
}

.task-column {
    background-color: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-main);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.task-column-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-color);
}

.task-column-header.pending { border-color: var(--warning); }
.task-column-header.done { border-color: var(--success); }

.task-column-title {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.task-count-badge {
    background-color: rgba(255, 255, 255, 0.05);
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.task-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 200px;
}

.task-item {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: all 0.2s ease;
}

.task-item:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.12);
}

.task-item-desc {
    font-size: 0.9rem;
    line-height: 1.4;
    white-space: pre-wrap;
}

.task-item-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    padding-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.task-device-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

.task-device-link:hover {
    text-decoration: underline;
}

.task-actions {
    display: flex;
    gap: 0.35rem;
}

/* UNIFIED INVENTARIO STYLING */
.inventario-grupos-container {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

.location-group {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-main);
    margin-bottom: 1.5rem;
    overflow: visible;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.location-group.flat-ip-group {
    overflow: hidden;
}

.location-group:hover {
    border-color: rgba(255, 255, 255, 0.08);
}

.location-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.01);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    user-select: none;
}

.location-title {
    display: flex;
    align-items: center;
    color: var(--text-main);
}

.location-title svg {
    color: var(--primary);
}

.arrow-icon {
    transition: transform 0.3s ease;
    color: var(--text-muted);
}

.location-body {
    max-height: 2000px;
    opacity: 1;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0, 1, 0, 1), opacity 0.3s ease, padding 0.3s ease;
}

.location-group.flat-ip-group .location-body {
    overflow: hidden;
    max-height: none;
    overflow-x: hidden;
}

.location-body.collapsed {
    max-height: 0;
    opacity: 0;
    border-bottom: none;
}

.location-header + .location-body.collapsed {
    border-top: none;
}

.location-header:hover .arrow-icon {
    color: var(--text-main);
}

.location-body.collapsed ~ .location-header .arrow-icon {
    transform: rotate(-90deg);
}
