@import url('../lib/fonts.css');

:root {
    /* Colors */
    --primary: #0d9488;
    --primary-hover: #0f766e;
    --primary-light: rgba(13, 148, 136, 0.08); /* Much softer */
    --bg-color: #f4f4f5; /* Zinc 100 */
    --surface-color: #ffffff;
    --text-primary: #0f172a; /* Slate 900 for sharper contrast */
    --text-secondary: #64748b; /* Slate 500 */
    --text-tertiary: #94a3b8; /* Slate 400 */
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.1);
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.1);
    
    /* Layout */
    --sidebar-width: 80px;
    
    /* Shapes */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    /* Shadows - Refined for "Exquisite" feel */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.02), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-float: 0 10px 40px -10px rgba(0,0,0,0.08);
    
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    /* Transitions */
    --transition: cubic-bezier(0.16, 1, 0.3, 1);
    --duration: 0.25s;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-color);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    height: 100vh;
    overflow: hidden;
    display: flex;
}

.font-mono { font-family: var(--font-mono); }

/* App Layout */
.app-container { display: flex; width: 100%; height: 100%; position: relative; }

/* --- Ultra Clean Iconic Sidebar (Ref Image 2) --- */
.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--surface-color);
    position: relative;
    height: 100%;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 99999;
    padding: 24px 0 0 0;
    transition: width 0.22s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.22s ease;
    overflow: hidden;
    will-change: width;
    transform: translateZ(0); /* Force GPU compositing layer */
}

/* Expands the sidebar on hover to show labels! */
.app-sidebar:hover {
    width: 240px;
    box-shadow: 10px 0 30px rgba(0,0,0,0.05);
    align-items: stretch;
}

.sidebar-brand {
    margin-bottom: 32px;
    position: relative;
    height: 44px;
    width: 100%;
}

.logo-collapsed {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%) scale(1);
    width: 44px;
    height: 44px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 1;
}

.logo-collapsed svg {
    width: 100%;
    height: 100%;
    display: block;
    
}

.logo-expanded {
    position: absolute;
    top: 50%;
    left: 24px;
    transform: translateY(-50%) translateX(-15px);
    width: 140px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0;
    pointer-events: none;
}

.logo-expanded svg {
    width: 100%;
    height: auto;
    display: block;
}

.app-sidebar:hover .logo-collapsed {
    opacity: 0;
    transform: translateX(-50%) scale(0.6);
    pointer-events: none;
}

.app-sidebar:hover .logo-expanded {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 10px; 
    width: 100%;
    align-items: center;
    flex: 1;
    min-height: 0; /* Crucial for scrolling inside flex box */
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 16px;
}

.nav-menu::-webkit-scrollbar {
    width: 0;
}

.app-sidebar:hover .nav-menu {
    align-items: stretch;
    padding-left: 16px;
    padding-right: 16px;
}

.sidebar-divider {
    width: 100%;
    height: 1px;
    background-color: rgba(0,0,0,0.08);
    border: none;
    margin: 8px auto;
    display: none;
    opacity: 0;
}

.app-sidebar:hover .sidebar-divider {
    display: block;
    animation: fadeIn 0.3s forwards 0.1s;
}

.sidebar-category {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 8px 0 0 16px;
    display: none;
    opacity: 0;
}

.app-sidebar:hover .sidebar-category {
    display: block;
    animation: fadeIn 0.3s forwards 0.1s;
}

.app-sidebar .nav-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px; 
    color: var(--text-secondary);
    transition: all var(--duration) var(--transition);
    cursor: pointer;
    position: relative;
    text-decoration: none;
    flex-shrink: 0;
    margin: 0 auto;
}

.app-sidebar:hover .nav-item {
    width: 100%;
    justify-content: flex-start;
    padding-left: 16px;
}

.app-sidebar .nav-item svg {
    width: 20px;
    height: 20px;
    stroke-width: 1.5; 
    transition: stroke var(--duration) ease;
    flex-shrink: 0;
}

.nav-text {
    margin-left: 16px;
    font-size: 14px;
    font-weight: 400;
    opacity: 0;
    white-space: nowrap;
    transition: opacity 0.2s ease;
    display: none;
}

.app-sidebar:hover .nav-text {
    display: block;
    animation: fadeIn 0.3s forwards 0.1s;
}

@keyframes fadeIn {
    to { opacity: 1; }
}

/* Hover State */
.app-sidebar .nav-item:hover {
    color: var(--primary);
    transform: translateY(-2px);
}

/* Active State - like Image 2 */
.app-sidebar .nav-item.active {
    background-color: #ecfdf5; /* Extremely light mint green */
    color: var(--primary);
}

.app-sidebar .nav-item.active svg {
    stroke-width: 2.2; /* Bolder icon when active */
}

/* Red Dot Badge */
.app-sidebar .nav-item .badge {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background-color: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--surface-color);
}
.app-sidebar .nav-item.active .badge {
    border-color: #ecfdf5;
}

/* User avatar at bottom */
.nav-bottom {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(0,0,0,0.04);
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
    width: 100%;
}

.app-sidebar:hover .nav-bottom {
    align-items: stretch;
}

.user-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid transparent;
    transition: all var(--duration) var(--transition);
}
.user-avatar:hover img {
    border-color: var(--primary);
    transform: scale(1.05);
}

/* Main Content Area - High-Tech Mesh Background */
.app-main {
    flex: 1;
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: #f8fafc;
    background-image:
        radial-gradient(circle at 0% 0%, rgba(45, 212, 191, 0.12), transparent 40%),
        radial-gradient(circle at 100% 20%, rgba(56, 189, 248, 0.12), transparent 50%),
        radial-gradient(circle at 80% 100%, rgba(16, 185, 129, 0.1), transparent 50%),
        radial-gradient(circle at 10% 80%, rgba(139, 92, 246, 0.08), transparent 40%);
    background-size: 100% 100%, 100% 100%, 100% 100%, 100% 100%;
    
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transform: translateZ(0); /* GPU compositing — prevents iframe relayout during sidebar transition */
    contain: layout style; /* Containment boundary — sidebar width change won't propagate deep relayout */
}

/* The sidebar natively pushes the layout now by acting as a fluid flex item. */

/* Danger Nav Item Styling */
.app-sidebar .nav-item.danger {
    color: var(--danger);
}

.app-sidebar .nav-item.danger:hover {
    background-color: var(--danger-light);
    color: var(--danger);
}

/* Sidebar User Layout (Bottom) */
.sidebar-user-row {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 65px; /* Rigidly fix to 65px to align with aiw-sidebar-footer on the right */
    padding: 0;
    position: relative;
}

/* Elegant dynamic divider above avatar */
.sidebar-user-row::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 48px; /* Tidy short line when collapsed */
    height: 1px;
    background: rgba(0,0,0,0.06);
    border-radius: 1px;
    transition: width 0.3s ease;
}

.app-sidebar:hover .sidebar-user-row::before {
    width: calc(100% - 40px); /* Stretches gracefully and smoothly on expand */
}

.app-sidebar:hover .sidebar-user-row {
    justify-content: flex-start;
    padding-left: 20px;
}

.sidebar-user-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 0; /* Removing left margin in collapsed state fixes avatar centering */
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
    width: 0;
    overflow: hidden;
}

.app-sidebar:hover .sidebar-user-actions {
    opacity: 1;
    pointer-events: auto;
    width: auto;
    margin-left: 16px; /* Expanding introduces margin smoothly */
    animation: fadeIn 0.3s forwards 0.1s;
}

/* Specific button styling for these quick actions */
.sidebar-user-actions .action-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.sidebar-user-actions .action-btn:hover {
    background: var(--bg-color);
    color: var(--primary);
}

.sidebar-user-actions .action-btn.danger:hover {
    color: var(--danger);
    background: var(--danger-light);
}

.sidebar-user-actions .action-btn svg {
    width: 20px;
    height: 20px;
    stroke-width: 2.2; /* Thicker and bolder icons */
}

/* Sidebar Glowing Avatar */
.sidebar-avatar-glow {
    animation: breatheAvatarGlow 3s infinite ease-in-out;
    outline: 0px solid transparent;
    outline-offset: 0px;
}

@keyframes breatheAvatarGlow {
    0% {
        outline: 0px solid rgba(13, 148, 136, 0);
        outline-offset: 0px;
    }
    50% {
        outline: 3px solid rgba(13, 148, 136, 0.18);
        outline-offset: 2px;
    }
    100% {
        outline: 0px solid rgba(13, 148, 136, 0);
        outline-offset: 0px;
    }
}

iframe.content-frame {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    background-color: transparent;
    transform: translateZ(0); /* Separate GPU layer — prevents relayout cascade from sidebar */
    contain: layout style paint; /* Full containment — iframe internals never relayout from external changes */
}

/* Pills */
.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 500;
}
.pill-primary { background-color: var(--primary-light); color: var(--primary); }
.pill-success { background-color: var(--success-light); color: var(--success); }
.pill-warning { background-color: var(--warning-light); color: var(--warning); }
.pill-danger { background-color: var(--danger-light); color: var(--danger); }

/* Globals for Modals (Used across iframe contents too via import) */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.7); /* Obscure background more since blur is gone */
    
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s var(--transition);
}

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

.modal-content {
    background: var(--surface-color);
    width: 500px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-float);
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    transition: all 0.4s var(--transition);
    overflow: hidden;
}

.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.modal-header {
    padding: 24px 32px;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    cursor: pointer;
    color: var(--text-tertiary);
    transition: color 0.2s;
}
.modal-close:hover { color: var(--danger); }

.modal-body {
    padding: 32px;
}

.modal-footer {
    padding: 16px 32px;
    background: var(--bg-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Button Reset */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--duration) var(--transition);
    border: none;
    outline: none;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 4px 12px var(--primary-light); }
.btn-primary:active { transform: scale(0.97); }
.btn-secondary { background: white; border: 1px solid rgba(0,0,0,0.1); color: var(--text-primary); }
.btn-secondary:hover { background: var(--bg-color); border-color: rgba(0,0,0,0.15); }

/* Custom Toast Notification System */
.toast-container {
    position: fixed;
    bottom: 32px;
    right: 32px;
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: 12px;
    pointer-events: none;
}

.toast {
    background: var(--surface-color);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 40px -10px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05);
    padding: 16px 24px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    min-width: 320px;
    max-width: 400px;
    pointer-events: auto;
    animation: toastSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast.fade-out {
    animation: toastFadeOut 0.3s ease forwards;
}

.toast-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.toast-icon.info { color: var(--primary); }
.toast-icon.success { color: var(--success); }

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.toast-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

@keyframes toastSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes toastFadeOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(20px); opacity: 0; }
}
.workspace {
    background-attachment: fixed !important;
}

/* Global Splash / Frame Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-color);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loading-overlay .spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--primary-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spinner-spin 1s linear infinite;
}

@keyframes spinner-spin {
    100% { transform: rotate(360deg); }
}
