/**
 * ================================================================================
 * SASTA INVITE - UNIFIED EDITOR STYLES
 * ================================================================================
 * Single stylesheet for the editor used in both admin and user modes.
 */

/* ==========================================
   EDITOR APP CONTAINER
   ========================================== */
.editor-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background: #f0f2f5;
}

.editor-app.admin-mode {
    --editor-primary: #667eea;
    --editor-sidebar-width: 320px;
}

.editor-app.user-mode {
    --editor-primary: #48bb78;
    --editor-sidebar-width: 280px;
}

/* ==========================================
   LOADING OVERLAY
   ========================================== */
.editor-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    gap: 1rem;
}

.editor-loading.hidden {
    display: none;
}

.loading-text {
    font-size: 1rem;
    color: #4a5568;
}

/* ==========================================
   EDITOR HEADER
   ========================================== */
.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    gap: 1rem;
    flex-shrink: 0;
    z-index: 100;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.editor-title {
    font-weight: 600;
    font-size: 1rem;
    color: #2d3748;
    display: flex;
    align-items: center;
}

.save-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: #f7fafc;
    border-radius: 20px;
    font-size: 0.75rem;
    color: #718096;
}

.save-indicator.saving {
    background: #fef3cd;
    color: #856404;
}

.save-indicator.saved {
    background: #d4edda;
    color: #155724;
}

.save-indicator.error {
    background: #f8d7da;
    color: #721c24;
}

.save-indicator i {
    font-size: 0.5rem;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* ==========================================
   EDITOR MAIN LAYOUT
   ========================================== */
.editor-main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ==========================================
   EDITOR SIDEBAR
   ========================================== */
.editor-sidebar {
    width: var(--editor-sidebar-width);
    background: white;
    border-right: 1px solid #e2e8f0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-section {
    padding: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.sidebar-section:last-child {
    border-bottom: none;
}

.sidebar-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
}

.sidebar-title i {
    color: var(--editor-primary);
}

/* User Mode Specific */
.user-mode .template-name {
    font-size: 1.25rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 0.5rem;
}

.user-mode .price-box {
    text-align: center;
    padding: 1rem;
    background: linear-gradient(135deg, #f7fafc, #edf2f7);
    border-radius: 10px;
}

.user-mode .price-label {
    font-size: 0.75rem;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.user-mode .price-amount {
    font-size: 2rem;
    font-weight: 700;
    color: #48bb78;
}

/* Thumbnail Preview */
.thumbnail-preview {
    width: 100%;
    aspect-ratio: 4/5;
    max-height: 150px;
    border: 2px dashed #e2e8f0;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f7fafc;
    overflow: hidden;
}

.thumbnail-preview.has-image {
    border-style: solid;
    border-color: #48bb78;
}

.thumbnail-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ==========================================
   CANVAS AREA
   ========================================== */
.editor-canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Canvas Toolbar */
.canvas-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.canvas-info {
    font-size: 0.75rem;
}

/* Canvas Wrapper */
.canvas-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow: auto;
    position: relative;
}

.canvas-container {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    background: white;
    position: relative;
}

/* Watermark handled by Fabric.js in editor.js (user mode only) */

/* ==========================================
   TEXT TOOLBAR
   ========================================== */
.text-toolbar {
    display: none;
    padding: 0.5rem 1rem;
    background: white;
    border-top: 1px solid #e2e8f0;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
    flex-shrink: 0;
}

.text-toolbar.visible {
    display: flex;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.5rem;
    background: #f7fafc;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.toolbar-group label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: #4a5568;
    margin: 0;
    white-space: nowrap;
}

.toolbar-group select,
.toolbar-group input[type="number"] {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    min-height: 28px;
}

.toolbar-group input[type="color"] {
    width: 28px;
    height: 28px;
    padding: 2px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    cursor: pointer;
}

.toolbar-btn {
    min-width: 32px;
    height: 32px;
    padding: 0.25rem;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    background: white;
    color: #4a5568;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.toolbar-btn:hover {
    background: #f0f0ff;
    border-color: var(--editor-primary);
    color: var(--editor-primary);
}

.toolbar-btn.active {
    background: var(--editor-primary);
    border-color: var(--editor-primary);
    color: white;
}

/* ==========================================
   FULLSCREEN MODE
   ========================================== */
.editor-app.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
}

.editor-app.fullscreen .editor-sidebar {
    display: none;
}

.editor-app.fullscreen .editor-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
}

/* ==========================================
   DRAFTS PANEL (USER MODE)
   ========================================== */
.drafts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.empty-drafts {
    color: #a0aec0;
}

.draft-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.draft-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: #f7fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.2s;
}

.draft-item:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.draft-item.active {
    background: #ebf8ff;
    border-color: #4299e1;
}

.draft-info {
    flex: 1;
    min-width: 0;
}

.draft-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: #2d3748;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.draft-date {
    font-size: 0.6875rem;
    color: #a0aec0;
}

.draft-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.draft-item:hover .draft-actions {
    opacity: 1;
}

.draft-actions .btn-link {
    padding: 0.25rem;
    color: #718096;
}

.draft-actions .btn-link:hover {
    color: #2d3748;
}

.draft-actions .btn-link.text-danger:hover {
    color: #e53e3e;
}

/* Completed Invitations */
.completed-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.completed-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: #f0fff4;
    border-radius: 8px;
    border: 1px solid #c6f6d5;
}

.completed-info {
    flex: 1;
    min-width: 0;
}

.completed-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: #276749;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.completed-date {
    font-size: 0.6875rem;
    color: #68d391;
}

.completed-actions .btn-success {
    padding: 0.25rem 0.5rem;
}

/* ==========================================
   ASSET PICKER
   ========================================== */
.asset-picker-panel {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fafbfc;
    overflow: hidden;
}

.asset-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: #f7fafc;
    border-bottom: 1px solid #e2e8f0;
    cursor: pointer;
}

.asset-picker-header:hover {
    background: #edf2f7;
}

.asset-picker-header .sidebar-title {
    margin: 0;
    font-size: 0.875rem;
}

#toggleAssetPicker {
    transition: transform 0.2s;
}

#toggleAssetPicker.collapsed {
    transform: rotate(-90deg);
}

.asset-picker-content {
    padding: 0.75rem;
    max-height: 400px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: max-height 0.3s ease;
}

.asset-picker-content.collapsed {
    max-height: 0;
    padding: 0 0.75rem;
}

.asset-search .input-group-text {
    border-right: none;
}

.asset-search .form-control {
    border-left: none;
}

.asset-search .form-control:focus {
    border-color: #ced4da;
    box-shadow: none;
}

/* Asset Type Tabs */
.asset-type-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    border-bottom: 1px solid #e2e8f0;
    margin: 0 -0.75rem;
    padding: 0 0.75rem;
    scrollbar-width: thin;
    gap: 2px;
}

.asset-type-tabs::-webkit-scrollbar {
    height: 4px;
}

.asset-type-tabs::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.asset-type-tabs .nav-item {
    flex-shrink: 0;
}

.asset-type-tabs .nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 0.75rem;
    font-size: 0.6875rem;
    color: #718096;
    border: none;
    border-radius: 6px 6px 0 0;
    background: transparent;
    transition: all 0.2s;
    min-width: 45px;
}

.asset-type-tabs .nav-link i {
    font-size: 0.875rem;
    margin-bottom: 2px;
}

.asset-type-tabs .nav-link:hover {
    color: var(--editor-primary);
    background: rgba(102, 126, 234, 0.1);
}

.asset-type-tabs .nav-link.active {
    color: var(--editor-primary);
    background: white;
    border-bottom: 2px solid var(--editor-primary);
    font-weight: 600;
}

/* Asset Grid Container */
.asset-grid-container {
    flex: 1;
    min-height: 150px;
    max-height: 280px;
    overflow-y: auto;
    margin: 0 -0.75rem;
    padding: 0.75rem;
    scrollbar-width: thin;
}

.asset-grid-container::-webkit-scrollbar {
    width: 6px;
}

.asset-grid-container::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 6px;
}

/* Asset Grid */
.asset-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.asset-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    background: white;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.asset-item:hover {
    border-color: var(--editor-primary);
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.asset-item:active {
    transform: scale(0.98);
}

.asset-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.asset-item .asset-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2px 4px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 0.625rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    transition: opacity 0.2s;
}

.asset-item:hover .asset-name {
    opacity: 1;
}

.asset-item.loading {
    background: #f7fafc;
    animation: pulse 1.5s infinite;
}

.asset-item.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.8);
}

/* Loading State */
.asset-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    flex-direction: column;
}

/* Empty State */
.asset-empty,
.asset-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
}

/* Sidebar Assets Section */
.sidebar-section-assets {
    padding: 0;
    margin: 0 -1rem;
    border-top: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
}

.sidebar-section-assets .asset-picker-panel {
    border: none;
    border-radius: 0;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 991px) {
    .editor-main {
        flex-direction: column;
    }
    
    .editor-sidebar {
        width: 100%;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }
    
    .canvas-wrapper {
        min-height: 50vh;
    }
    
    .header-center {
        display: none;
    }
    
    .asset-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 576px) {
    .editor-header {
        flex-wrap: wrap;
        padding: 0.5rem;
    }
    
    .header-left,
    .header-right {
        flex: 1 1 100%;
        justify-content: space-between;
    }
    
    .zoom-controls {
        display: none;
    }
    
    .canvas-toolbar {
        overflow-x: auto;
    }
    
    .text-toolbar {
        overflow-x: auto;
    }
    
    .asset-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
