@import url('../../style/dashboard.css');

/* Uploader Dashboard Styles - Integration with dashboard header */

/* Override uploader theme to match dashboard */
/* Override uploader theme to match dashboard */
body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    /* Use dashboard defaults */
    background: #f0f2f5;
}

/* Dashboard header - Match dashboard.css exactly */
.dashboard-header {
    background: #ffffff !important;
    border-bottom: 1px solid #e9ecef !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 1010 !important;
    padding: 0 2rem !important;
    margin: 0 !important;
    box-shadow: none !important;
}

/* Dashboard header content */
.dashboard-header-content {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    height: 70px !important;
}

/* Container starts at top (no margin needed for sticky header) */
/* Container starts at top (no margin needed for sticky header) */
.workspace-container {
    margin-top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 100% !important;
    width: 100% !important;
    padding: 0 !important;
}

/* Toolbar styling - Glass effect */
.uploader-toolbar {
    padding: 15px;
    background: white;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
}

.toolbar-left {
    display: flex;
    gap: 10px;
}

.toolbar {
    padding: 15px;
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

/* Main content takes remaining space - Full width */
.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
    width: 100%;
    max-width: 100%;
}

/* Sidebar styling - Glass effect */
.sidebar {
    width: 300px;
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-right: 1px solid rgba(255, 255, 255, 0.2) !important;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
    overflow-y: auto;
    flex-shrink: 0;
}

/* Sidebar sections styling */
.sidebar .tool-panel {
    padding: 1rem;
}

.sidebar .tools-section {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Canvas area takes remaining space */
.canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Properties panel - Glass effect */
.properties-panel {
    width: 300px;
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-left: 1px solid rgba(255, 255, 255, 0.2) !important;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.05);
    overflow-y: auto;
    flex-shrink: 0;
}

/* Properties sections styling */
.properties-panel .properties-section {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Canvas container - quadrato e sempre visibile */
.canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: rgba(248, 249, 250, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 20px 40px 20px;
    /* Più spazio sotto per staccare dal fondo */
}

/* Wrapper per il canvas che contiene anche i rettangoli guida */
#canvas3DContainer {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Il container si espande per riempire tutto lo spazio disponibile */
    width: 100%;
    height: 100%;
    max-height: calc(100vh - 200px);
    /* Rimosso aspect-ratio per permettere al canvas di allargarsi */
}

#canvas3D {
    /* Canvas quadrato - riempie completamente il container */
    width: 100% !important;
    height: 100% !important;
    display: block;
}

/* Rettangolo rosso guida - quadrato perfetto che sta dentro il canvas */
#canvas3DContainer::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /* Altezza ridotta per stare dentro il canvas, larghezza = altezza (quadrato perfetto) */
    height: 94%;
    aspect-ratio: 1 / 1;
    /* width viene calcolato automaticamente come height (grazie a aspect-ratio) */
    border: 3px solid rgba(255, 0, 0, 0.7);
    pointer-events: none;
    z-index: 10;
    box-sizing: border-box;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.3);
}

/* Rettangolo giallo interno - guida per centrare l'oggetto, sempre quadrato */
#canvas3DContainer::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /* Altezza relativa al rettangolo rosso (65% di 94% = ~61% del canvas) */
    height: 61%;
    aspect-ratio: 1 / 1;
    /* width viene calcolato automaticamente = height (sempre quadrato) */
    border: 2px dashed rgba(255, 200, 0, 0.8);
    pointer-events: none;
    z-index: 11;
    box-sizing: border-box;
    box-shadow: 0 0 8px rgba(255, 200, 0, 0.3);
}

/* Upload Preview Image - sfondo bianco */
#uploadPreviewImage {
    background-color: white;
    padding: 10px;
    object-fit: contain;
}

/* Button styling - Match dashboard */
.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border: none !important;
    padding: 0.75rem 1.5rem !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    cursor: pointer;
    transition: all 0.3s ease !important;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.3) !important;
}

.btn-primary:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4) !important;
}

.btn-primary:active {
    transform: translateY(0) !important;
}

.btn-secondary {
    background: #6c757d !important;
    color: white !important;
    border: none !important;
    padding: 0.75rem 1.5rem !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    cursor: pointer;
    transition: all 0.3s ease !important;
}

.btn-secondary:hover {
    background: #5a6268 !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3) !important;
}

.btn-secondary:active {
    transform: translateY(0) !important;
}

/* Toolbar buttons styling */
.toolbar .btn {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Details/Summary (Accordion) Styling */
details {
    transition: all 0.3s ease;
}

details summary {
    list-style: none;
    cursor: pointer;
    padding: 10px 12px;
    background: rgba(33, 150, 243, 0.08);
    border-radius: 6px;
    transition: all 0.2s ease;
    user-select: none;
}

details summary:hover {
    background: rgba(33, 150, 243, 0.15);
}

details[open] summary {
    background: rgba(33, 150, 243, 0.12);
    margin-bottom: 8px;
}

/* Remove default triangle */
details summary::-webkit-details-marker {
    display: none;
}

details summary::before {
    content: '▶';
    display: inline-block;
    margin-right: 8px;
    transition: transform 0.2s ease;
    font-size: 10px;
    color: #2196F3;
}

details[open] summary::before {
    transform: rotate(90deg);
}

/* Input styling improvements */
input[type="number"],
input[type="text"],
select {
    transition: all 0.2s ease;
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
    outline: none;
    border-color: #667eea !important;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
    transition: all 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.5);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    border-radius: 50%;
    border: none;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
    transition: all 0.2s ease;
}

input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.5);
}

/* Color picker styling */
input[type="color"] {
    cursor: pointer;
    transition: all 0.2s ease;
}

input[type="color"]:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Button disabled state */
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn:disabled:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* Scrollbar styling for sidebar */
.sidebar::-webkit-scrollbar,
.properties-panel::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track,
.properties-panel::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

.sidebar::-webkit-scrollbar-thumb,
.properties-panel::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.properties-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.5);
}

/* Loading Spinner */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Object Card in Modal */
.object-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.object-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.object-preview {
    width: 100%;
    height: 200px;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.object-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.object-category-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    color: #667eea;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.object-info {
    padding: 15px;
}

.object-name {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin: 0 0 10px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.object-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #666;
}

.meta-item i {
    font-size: 16px;
    color: #999;
}

.object-actions {
    display: flex;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

.object-actions button {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.btn-edit-object {
    background: #e8f5e9;
    color: #4CAF50;
}

.btn-edit-object:hover {
    background: #4CAF50;
    color: white;
    transform: translateY(-2px);
}

.btn-edit-3d-object {
    background: #e3f2fd;
    color: #2196F3;
}

.btn-edit-3d-object:hover {
    background: #2196F3;
    color: white;
    transform: translateY(-2px);
}

.btn-delete-object {
    background: #fff0f0;
    color: #f5576c;
}

.btn-delete-object:hover {
    background: #f5576c;
    color: white;
    transform: translateY(-2px);
}

.object-preview .placeholder {
    font-size: 48px;
    color: #ccc;
}

/* Rotating icon animation for save button */
@keyframes rotating {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.rotating {
    animation: rotating 1s linear infinite;
}

.btn-success {
    background: #28a745 !important;
    color: white !important;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-success:hover {
    background: #218838 !important;
    transform: translateY(-1px);
}

.btn-danger {
    background: #f5576c !important;
    color: white !important;
}

.btn-danger:hover {
    background: #e04558 !important;
}

/* --- OBJECT MANAGEMENT MODAL ENHANCEMENTS --- */
.modal-manage-content {
    max-width: 1000px !important;
    width: 95% !important;
    max-height: 90vh !important;
    height: 85vh !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
    margin: 5vh auto !important;
    overflow: hidden !important;
}

.filters-wrapper {
    padding: 20px 25px !important;
    background: #f8f9fa !important;
    border-bottom: 1px solid #eee !important;
    flex-shrink: 0 !important;
}

.filters-row {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 12px !important;
    align-items: center !important;
}

.filter-input {
    padding: 10px 15px !important;
    border: 1px solid #ddd !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    min-width: 180px !important;
}

.filter-input-search {
    flex: 1 !important;
    min-width: 250px !important;
}

.flex-row-center-between {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
}

.flex-row-center-gap-5 {
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
}

/* Ensure the grid container takes the remaining space and is scrollable */
#objectsListContainer {
    flex: 1 !important;
    overflow-y: auto !important;
    padding: 25px !important;
}

#objectsGrid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)) !important;
    gap: 20px !important;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .properties-panel {
        width: 250px;
    }

    .sidebar {
        width: 250px;
    }
}

@media (max-width: 768px) {

    .sidebar,
    .properties-panel {
        position: absolute;
        z-index: 100;
        height: 100%;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.active,
    .properties-panel.active {
        transform: translateX(0);
    }

    /* Hide user email and plan text on mobile, keep only avatar and name */
    .user-info {
        max-width: 150px;
    }

    .user-email,
    .user-plan {
        display: none !important;
    }

    .user-name {
        font-size: 0.8125rem;
    }

    .user-avatar {
        width: 36px;
        height: 36px;
        font-size: 0.8125rem;
    }

    /* Reduce header padding on mobile */
    .header-container {
        padding: 0 1rem !important;
    }

    .header-right-section {
        gap: 0.75rem;
    }

    /* Hide notification badge number on mobile */
    .notification-badge {
        font-size: 0.625rem;
        min-width: 16px;
        height: 16px;
        padding: 0 0.25rem;
    }

    /* Adjust dashboard label */
    .dashboard-label {
        font-size: 0.875rem;
        margin-left: 0.5rem;
        padding-left: 0.5rem;
    }

    /* Ensure logo is readable on mobile */
    .logo {
        font-size: 1.25rem !important;
    }

    /* Stack toolbar buttons on mobile */
    .toolbar {
        flex-wrap: wrap;
        padding: 10px;
    }

    .toolbar .btn {
        font-size: 0.8125rem;
        padding: 0.625rem 1rem !important;
    }

    /* Manage Objects Modal Responsive */
    #manageObjectsModal .modal-content {
        max-width: 95% !important;
        max-height: 95vh !important;
        margin: 2.5vh auto;
    }

    #manageObjectsModal h2 {
        font-size: 1.25rem !important;
        padding: 15px 15px 0 15px !important;
    }

    .object-filters-container {
        padding: 0 15px 12px 15px !important;
    }

    .object-filters-container input,
    .object-filters-container select {
        font-size: 13px !important;
        padding: 8px 12px !important;
        min-width: 100px !important;
    }

    .object-filters-container input[type="text"] {
        width: 100%;
        min-width: 100% !important;
    }

    .object-filters-container .btn {
        padding: 8px 12px !important;
        font-size: 13px !important;
    }

    /* Hide text labels on mobile, keep only icons */
    .btn-text-desktop {
        display: none;
    }

    #objectsListContainer {
        padding: 15px !important;
    }

    #objectsGrid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    .object-card {
        max-width: 100%;
    }
}