@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

body.workspace-active {
    font-family: 'Inter', sans-serif;
    background-color: #f8fafc;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

/* Base Layout */
.ie-workspace {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    background: #f4f5f7;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100; /* overlay everything */
}

/* Header */
.ie-header {
    height: 72px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    flex-shrink: 0;
}

.ie-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e40af;
}

.ie-header-center {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.ie-action-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    color: #4b5563;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.375rem 0.5rem;
    border-radius: 0.375rem;
    transition: all 0.2s;
}

.ie-action-btn:hover:not(:disabled) {
    color: #111827;
    background: #f3f4f6;
}

.ie-action-btn:disabled {
    color: #9ca3af;
    opacity: 0.5;
    cursor: not-allowed;
}

.ie-header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.ie-btn-outline {
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #374151;
    padding: 0.5rem 1rem;
    border-radius: 9999px; /* full rounded */
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    cursor: pointer;
}

.ie-btn-outline:hover {
    background: #f3f4f6;
}

.ie-btn-primary {
    background: linear-gradient(to right, #60a5fa, #3b82f6);
    color: #ffffff;
    padding: 0.5rem 1.25rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.2);
}

.ie-btn-primary:hover {
    opacity: 0.9;
}

/* Main Area */
.ie-main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Left Narrow Sidebar */
.ie-nav-narrow {
    width: 64px;
    background: transparent;
    border-right: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 0;
    gap: 1.5rem;
    flex-shrink: 0;
}

.ie-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    color: #6b7280;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    border: none;
    background: transparent;
}

.ie-nav-item.is-active {
    color: #3b82f6;
}

.ie-nav-icon {
    width: 24px;
    height: 24px;
    padding: 4px;
    border-radius: 50%;
}

.ie-nav-item.is-active .ie-nav-icon {
    background: #eff6ff;
    color: #3b82f6;
}

/* Left Wide Panel */
.ie-panel-wide {
    width: 280px;
    background: #ffffff;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

/* Right Panel */
.ie-panel-right {
    width: 260px;
    background: #ffffff;
    border-left: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.ie-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.ie-tool-section {
    margin-bottom: 2rem;
}

.ie-tool-section-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 0.75rem;
}

.ie-tool-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1rem;
    background: #f9fafb;
    border-radius: 0.75rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.ie-tool-card:hover {
    background: #f3f4f6;
}

.ie-tool-card.is-active {
    background: #e0e7ff; /* light indigo */
    border-color: #c7d2fe;
}

.ie-tool-card-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #374151;
    font-size: 0.875rem;
    font-weight: 600;
}

.ie-tool-card.is-active .ie-tool-card-left {
    color: #4f46e5;
}

.ie-tool-card-arrow {
    color: #9ca3af;
}

/* Tool Detail Panel (replaces tool list when active) */
.ie-detail-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.ie-btn-back {
    background: #f3f4f6;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #4b5563;
}

.ie-detail-title {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
}

.ie-form-group {
    margin-bottom: 1rem;
}

.ie-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

.ie-select, .ie-input {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: #111827;
    background: #ffffff;
    outline: none;
}

.ie-select:focus, .ie-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.ie-btn-apply {
    width: 100%;
    background: #3b82f6;
    color: #ffffff;
    padding: 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    margin-top: 1rem;
}

.ie-btn-apply:hover {
    background: #2563eb;
}

/* Canvas Area */
.ie-canvas-area {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: auto;
}

.ie-canvas-container {
    background: repeating-conic-gradient(#e5e7eb 0% 25%, #ffffff 0% 50%) 50% / 20px 20px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    position: relative;
}

#main-canvas,
#mask-canvas {
    display: block;
}

/* Floating AI Input Box */
.ie-floating-ai {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: #ffffff;
    border-radius: 9999px;
    padding: 0.5rem 0.5rem 0.5rem 1.5rem;
    display: flex;
    align-items: center;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    width: 500px;
    border: 1px solid #f3f4f6;
}

.ie-floating-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 0.875rem;
    color: #374151;
    background: transparent;
}

.ie-floating-input::placeholder {
    color: #9ca3af;
}

.ie-floating-btn {
    background: #e0e7ff;
    color: #ffffff;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    border: none;
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    cursor: pointer;
    transition: background 0.2s;
}

.ie-floating-btn.active {
    background: #4f46e5;
}

.ie-floating-btn-icon {
    width: 16px;
    height: 16px;
}

/* Loading Overlay */
.ie-loading-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.ie-spinner {
    width: 40px; height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: ie-spin 1s linear infinite;
}

@keyframes ie-spin { to { transform: rotate(360deg); } }

/* Mobile Redesign (max-width: 768px) */
.ie-desktop-only { display: flex !important; }
.ie-mobile-only { display: none !important; }

@media (max-width: 768px) {
    .ie-desktop-only { display: none !important; }
    .ie-mobile-only { display: flex !important; }
    
    .ie-workspace {
        flex-direction: column;
    }
    
    .ie-header {
        padding: 0 0.75rem;
        height: 56px;
    }
    
    .ie-mobile-back {
        color: #374151;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
    }
    
    .ie-filename-input {
        width: 180px;
    }
    
    .ie-main {
        flex-direction: column;
        padding-bottom: 80px; /* Space for bottom bar */
    }
    
    .ie-panel-wide {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100vw;
        height: auto;
        border-right: none;
        border-top: 1px solid #e5e7eb;
        z-index: 50;
        max-height: 50vh;
    }
    
    #panel-tools-list {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        padding: 0.5rem;
        gap: 0.5rem;
        white-space: nowrap;
        background: #ffffff;
    }
    
    .ie-tool-section {
        display: none;
        flex-direction: row;
        gap: 0.5rem;
        margin-bottom: 0;
    }
    
    .ie-tool-section.mobile-active-section {
        display: flex;
    }
    
    .ie-tool-section-title {
        display: none; /* Hide section titles on mobile */
    }
    
    .ie-tool-card {
        flex-direction: column;
        justify-content: center;
        padding: 0.5rem;
        margin-bottom: 0;
        min-width: 72px;
        border-radius: 0.5rem;
        gap: 0.25rem;
    }
    
    .ie-tool-card-left {
        flex-direction: column;
        font-size: 0.75rem;
        font-weight: 500;
        gap: 0.25rem;
    }
    
    .ie-tool-card-arrow {
        display: none;
    }
    
    /* Panel Params Drawer */
    #panel-tool-params {
        padding: 1rem;
        background: #ffffff;
        max-height: 40vh;
        overflow-y: auto;
    }
    
    .ie-mobile-floating-actions {
        position: absolute;
        top: 0.5rem;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        gap: 0.5rem;
        z-index: 40;
    }
    
    .ie-floating-action-btn {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.9);
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        border: 1px solid #e5e7eb;
        color: #4b5563;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }
    
    .ie-floating-action-btn:disabled {
        opacity: 0.5;
        color: #9ca3af;
    }
}

/* AI Text Edit Tabs UI */
.ai-tab-nav {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 0.5rem;
}
.ai-tab-btn {
    flex: 1;
    text-align: center;
    padding: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #6b7280;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}
.ai-tab-btn.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
}
.ai-tab-content {
    display: none;
}
.ai-tab-content.active {
    display: block;
}
.ai-text-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
}
.ai-text-grid-item {
    padding: 0.5rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    text-align: center;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ai-text-grid-item.active {
    background: #eff6ff;
    border-color: #3b82f6;
    color: #1d4ed8;
}
.ai-style-nav {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}
.ai-style-btn {
    flex: 1;
    text-align: center;
    padding: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #4b5563;
    background: #f3f4f6;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
}
.ai-style-btn.active {
    background: #e0e7ff;
    color: #4f46e5;
}
.ai-style-content {
    display: none;
    padding-top: 0.5rem;
}
.ai-style-content.active {
    display: block;
}
