/* ============================================================
   layout.css — Struttura e layout dell'applicazione
   Reset, sidebar, content-area, top-menu, work-area, fullscreen
   ============================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f8fafc;
    height: 100vh;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* ================================
   LOGIN LAYOUT
   ================================ */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 32px;
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.login-box h2 {
    color: #2d3748;
    margin-bottom: 16px;
}

.login-box input {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: 10px;
    border: 2px solid #e2e8f0;
    font-size: 15px;
}

/* ================================
   APP CONTAINER
   ================================ */
.app-container {
    display: flex;
    height: 100vh;
    background: #f8fafc;
    overflow: hidden;
}

/* ================================
   SIDEBAR
   ================================ */
.sidebar {
    width: 280px;
    background: white;
    border-right: 1px solid #e2e8f0;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
    transition: width 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed {
    width: 64px;
}

.app-header {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 88px;
}

.sidebar.collapsed .app-header {
    justify-content: center;
    padding: 24px 0;
}

.app-logo {
    width: 40px;
    height: 40px;
    background: #dc2626;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.app-logo:hover {
    background: #b91c1c;
    transform: scale(1.05);
}

.app-logo svg {
    width: 28px;
    height: 28px;
    pointer-events: none;
}

.app-name {
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
    transition: opacity 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar.collapsed .app-name {
    opacity: 0;
    width: 0;
}

/* ================================
   NAVIGATION
   ================================ */
.nav-menu {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 14px 24px;
    color: #64748b;
    transition: all 0.2s ease;
    cursor: pointer;
    gap: 12px;
    position: relative;
    height: 52px;
}

.sidebar.collapsed .nav-item {
    padding: 14px 0;
    justify-content: center;
}

.nav-item:hover {
    background: #f1f5f9;
    color: #334155;
}

.nav-item.active {
    background: #475569;
    color: white;
}

.nav-item.active .nav-icon {
    filter: brightness(0) invert(1);
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-text {
    font-weight: 500;
    transition: opacity 0.2s ease;
}

.sidebar.collapsed .nav-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.nav-item .tooltip {
    position: fixed;
    left: 72px;
    transform: translateY(-50%);
    background: #1e293b;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 20000;
}

.tooltip::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-right-color: #1e293b;
}

/* ================================
   CONTENT AREA
   ================================ */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f8fafc;
    min-width: 0;
}

/* ================================
   TOP MENU
   ================================ */
.top-menu {
    background: #f8fafc;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 80px;
}

.top-menu-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.section-title-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-menu {
    position: relative;
}

.menu-icon {
    width: 24px;
    height: 24px;
    cursor: pointer;
    color: #475569;
    transition: color 0.2s ease;
}

.menu-icon:hover {
    color: #1e293b;
}

.section-title {
    font-size: 24px;
    font-weight: 700;
    color: #1e293b;
}

.top-menu-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

#dynamicActions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ================================
   WORK AREA
   ================================ */
.work-area {
    flex: 1;
    padding: 24px;
    background: #f8fafc;
    overflow-y: auto;
}

/* ================================
   FULLSCREEN MODE
   ================================ */
#mainApp.fullscreen .sidebar,
#mainApp.fullscreen .top-menu {
    display: none;
}

#mainApp.fullscreen .work-area {
    height: 100vh;
}

#exitFullscreenBtn {
    display: none;
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 10000;
    background: rgba(30, 41, 59, 0.35);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    transition: background 0.2s ease, transform 0.2s ease;
}

#exitFullscreenBtn img {
    filter: brightness(0) invert(1);
    display: block;
}

#exitFullscreenBtn:hover {
    background: rgba(30, 41, 59, 0.70);
    transform: translateY(-1px);
}

#mainApp.fullscreen ~ #exitFullscreenBtn,
body.fullscreen-active #exitFullscreenBtn {
    display: flex;
}

/* ================================
   RESPONSIVE
   ================================ */
@media (max-width: 768px) {
    .modal-content.modal-lg {
        max-width: 95%;
    }

    .modal-flex .modal-footer {
        flex-direction: column;
    }

    .modal-flex .modal-footer .btn {
        width: 100%;
    }
}
