/* ============================================
   PORTFOLIOSHIELD DESIGN SYSTEM
   2-LAYOUT.CSS

   App Shell: Sidebar | Header | Panels
   ⚠️ FROZEN COMPONENTS - DO NOT MODIFY STRUCTURE
   ============================================ */

/* ============================================
   LAYOUT STRUCTURE
   ============================================ */

.app-layout-v2 {
    display: flex;
    min-height: 100vh;
    background: var(--bg-primary);
}


/* ============================================
   MAIN AREA
   ============================================ */

.main-area {
    flex: 1;
    margin-left: var(--sidebar-collapsed);
    transition: margin-left var(--sidebar-transition);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;  /* Prevent horizontal scroll when sidebar expands */
    max-width: calc(100vw - var(--sidebar-collapsed));
}

.sidebar.expanded ~ .main-area {
    margin-left: var(--sidebar-expanded);
    max-width: calc(100vw - var(--sidebar-expanded));
}

/* ============================================
   HEADER — FROZEN COMPONENT
   ============================================ */

.app-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: var(--z-header);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Header Row 1 */
.app-header .header-row1 {
    height: var(--header-row-height);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    background: var(--bg-secondary);
}

.app-header .screen-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.app-header .header-separator {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
}

/* Header metrics — authoritative styles in header.css (#app-header)
   These are low-specificity fallbacks only. header.css rules always win.
   Values here MUST match header.css canonical sizes. */
.app-header .header-metrics {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.app-header .metric-item {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 5px;
    min-width: 0;
    flex-shrink: 1;
    white-space: nowrap;
}

.app-header .metric-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.app-header .metric-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.app-header .metric-value.positive {
    color: var(--accent-green);
}

.app-header .metric-value.negative {
    color: var(--accent-red);
}

.app-header .metric-value.warning {
    color: var(--accent-yellow);
}

.app-header .metrics-toggle {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 12px;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.app-header .metrics-toggle:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.app-header .header-icons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-header .icon-btn {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 18px;
    position: relative;
}

.app-header .icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
    z-index: 10001;
}

.app-header .connection-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-yellow);
    animation: pulse 2s ease-in-out infinite;
}

.app-header .connection-dot.connected {
    background: var(--accent-green);
}

.app-header .connection-dot.error {
    background: var(--accent-red);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.app-header .user-avatar {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
}

/* Header Row 2 - SGE Banner — FROZEN COMPONENT */
.app-header .header-row2 {
    height: var(--header-row-height);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px;
    transition: height 0.3s ease, opacity 0.3s ease, border-bottom 0.3s ease;
    overflow: hidden;
}

.app-header .header-row2.hidden {
    height: 0;
    opacity: 0;
    padding: 0 24px;
    border-bottom: none;
}

.app-header .header-row2.critical {
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.2), rgba(239, 68, 68, 0.05));
    border-bottom: 2px solid rgba(239, 68, 68, 0.5);
}

.app-header .header-row2.action {
    background: linear-gradient(90deg, rgba(249, 115, 22, 0.2), rgba(249, 115, 22, 0.05));
    border-bottom: 2px solid rgba(249, 115, 22, 0.5);
}

.app-header .header-row2.monitor {
    background: linear-gradient(90deg, rgba(251, 191, 36, 0.15), rgba(251, 191, 36, 0.05));
    border-bottom: 2px solid rgba(251, 191, 36, 0.3);
}

.app-header .header-row2.info {
    background: linear-gradient(90deg, rgba(74, 222, 128, 0.1), rgba(74, 222, 128, 0.02));
    border-bottom: 2px solid rgba(74, 222, 128, 0.3);
}

.app-header .sge-icon {
    font-size: 20px;
}

.app-header .sge-message {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
}

.app-header .sge-actions {
    display: flex;
    gap: 8px;
}

.app-header .sge-btn {
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.app-header .sge-btn.primary {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

.app-header .sge-btn.primary:hover {
    background: rgba(255, 255, 255, 0.25);
}

.app-header .sge-btn.secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.app-header .sge-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

/* ============================================
   CONTENT AREA
   ============================================ */

.content {
    flex: 1;
    padding: 16px 24px 24px 24px;
    overflow-y: auto;
}

/* ============================================
   PANELS
   ============================================ */

.panel {
    position: fixed;
    top: 0;
    height: 100vh;
    width: var(--panel-width);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    z-index: var(--z-panel);
    transition: transform var(--panel-transition);
}

.panel-left {
    left: 0;
    border-left: none;
    transform: translateX(-100%);
}

.panel-left.open {
    transform: translateX(0);
}

.panel-right {
    right: 0;
    border-right: none;
    transform: translateX(100%);
}

.panel-right.open {
    transform: translateX(0);
}

.panel-header {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-card);
}

.panel-icon {
    font-size: 24px;
    margin-right: 8px;
}

.panel-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
}

.panel-close {
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 18px;
    transition: all 0.2s ease;
}

.panel-close:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.panel-search {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.panel-search input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
}

.panel-search input::placeholder {
    color: var(--text-muted);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* AI Panel Specific */
.ai-context {
    padding: 16px;
    background: rgba(74, 222, 128, 0.1);
    border-bottom: 1px solid rgba(74, 222, 128, 0.2);
    font-size: 13px;
    color: var(--text-secondary);
}

.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.ai-input-area {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
    display: flex;
    gap: 8px;
}

.ai-input-area input {
    flex: 1;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
}

.ai-input-area button {
    width: 40px;
    height: 40px;
    background: var(--accent-blue);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-input-area button:hover {
    background: var(--accent-purple);
    transform: scale(1.05);
}

/* User Panel Specific */
.user-profile {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px;
    background: var(--bg-card);
    border-radius: 12px;
    margin-bottom: 16px;
}

.user-avatar-large {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 600;
    color: white;
    margin-bottom: 12px;
}

.user-avatar-large svg {
    width: 40px;
    height: 40px;
}

.user-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.user-email {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.user-plan {
    padding: 4px 12px;
    background: rgba(74, 222, 128, 0.2);
    color: var(--accent-green);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.user-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 14px;
}

.user-menu-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    transform: translateX(4px);
}

.user-menu-item span:first-child {
    font-size: 18px;
}

.user-footer {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.user-session {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-align: center;
}

.btn-logout {
    width: 100%;
    padding: 10px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    color: var(--accent-red);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    z-index: var(--z-panel-overlay);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--panel-transition);
}

.overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .main-area {
        margin-left: 0;
    }

    .panel {
        width: 100%;
    }
}

/* ── Legal Disclaimer Footer ── */
.ps-legal-footer {
    padding: 10px 24px;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    border-top: 1px solid var(--border-color, rgba(255,255,255,0.06));
    margin-top: auto;
    letter-spacing: 0.01em;
    opacity: 0.7;
}
.ps-legal-footer a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}
.ps-legal-footer a:hover {
    color: var(--text-secondary);
}
