/* =============================================================================
   GVision Design Studio - Stylesheet
   ============================================================================= */

:root {
    --primary: #0066cc;
    --primary-dark: #004c99;
    --secondary: #6c757d;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --light: #f8f9fa;
    --dark: #343a40;
    --white: #ffffff;
    --border: #dee2e6;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --radius: 8px;
    --sidebar-width: 220px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--light);
    color: var(--dark);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* =============================================================================
   Header
   ============================================================================= */

.header {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    z-index: 100;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-brand .logo {
    height: 32px;
}

.header-brand h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary);
}

.header-nav {
    display: flex;
    gap: 8px;
}

.nav-link {
    padding: 8px 16px;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--secondary);
    font-weight: 500;
    transition: all 0.2s;
}

.nav-link:hover {
    background: var(--light);
    color: var(--dark);
}

.nav-link.active {
    background: var(--primary);
    color: var(--white);
}

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

/* =============================================================================
   Buttons
   ============================================================================= */

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--secondary);
    color: var(--white);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* =============================================================================
   Designer Layout
   ============================================================================= */

.designer-container {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* =============================================================================
   Sidebar
   ============================================================================= */

.sidebar {
    width: var(--sidebar-width);
    background: var(--white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-right {
    border-right: none;
    border-left: 1px solid var(--border);
}

.sidebar-section {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-section h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--dark);
}

.sidebar-hint {
    font-size: 0.75rem;
    color: var(--secondary);
    margin-bottom: 12px;
}

/* =============================================================================
   Camera List (Sidebar)
   ============================================================================= */

.camera-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.camera-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--light);
    border-radius: var(--radius);
    cursor: grab;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.camera-item:hover {
    border-color: var(--primary);
    background: #e8f4ff;
}

.camera-item:active {
    cursor: grabbing;
}

.camera-item .camera-icon {
    font-size: 1.5rem;
}

.camera-item .camera-info {
    flex: 1;
}

.camera-item .camera-name {
    font-weight: 500;
    font-size: 0.85rem;
}

.camera-item .camera-type {
    font-size: 0.75rem;
    color: var(--secondary);
}

/* =============================================================================
   Lens List
   ============================================================================= */

.lens-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.lens-item {
    padding: 6px 12px;
    background: var(--light);
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.lens-item:hover,
.lens-item.active {
    background: var(--primary);
    color: var(--white);
}

/* =============================================================================
   Map Container
   ============================================================================= */

.map-container {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 70vh;
}

#map {
    flex: 1;
    z-index: 1;
}

.map-toolbar {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    z-index: 1000;
    display: flex;
    gap: 8px;
    background: var(--white);
    padding: 8px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.search-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.map-info {
    position: absolute;
    bottom: 10px;
    left: 10px;
    z-index: 1000;
    display: flex;
    gap: 16px;
    background: var(--white);
    padding: 10px 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-weight: 500;
}

/* =============================================================================
   Properties Panel
   ============================================================================= */

.property-group {
    margin-bottom: 16px;
}

.property-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--secondary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.form-range {
    width: 100%;
}

.fov-info {
    background: var(--light);
    border-radius: var(--radius);
    padding: 12px;
}

.fov-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.fov-row:last-child {
    border-bottom: none;
}

/* =============================================================================
   Modal
   ============================================================================= */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal-small {
    max-width: 400px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.1rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--secondary);
}

.modal-body {
    padding: 20px;
}

/* =============================================================================
   Preview Grid (Modal)
   ============================================================================= */

.preview-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.preview-item {
    text-align: center;
}

.preview-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.preview-label {
    margin-top: 8px;
}

.preview-label strong {
    display: block;
    font-size: 1rem;
}

.preview-label span {
    display: block;
    font-size: 0.8rem;
    color: var(--secondary);
}

.preview-label .ppm {
    color: var(--primary);
    font-weight: 500;
}

/* =============================================================================
   Projects Page
   ============================================================================= */

.projects-container {
    padding: 30px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.projects-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.project-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}

.project-card:hover {
    transform: translateY(-2px);
}

.project-icon {
    font-size: 2.5rem;
}

.project-info {
    flex: 1;
}

.project-info h3 {
    font-size: 1rem;
    margin-bottom: 4px;
}

.project-info p {
    font-size: 0.85rem;
    color: var(--secondary);
}

.project-info small {
    font-size: 0.75rem;
    color: var(--secondary);
}

.project-actions {
    display: flex;
    gap: 6px;
}

/* =============================================================================
   Empty State
   ============================================================================= */

.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.empty-state p {
    color: var(--secondary);
    margin-bottom: 20px;
}

/* =============================================================================
   Leaflet Custom Styles
   ============================================================================= */

.camera-marker {
    background: var(--primary);
    border: 3px solid var(--white);
    border-radius: 50%;
    width: 30px !important;
    height: 30px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    cursor: move;
}

.camera-marker.selected {
    background: var(--warning);
    border-color: var(--dark);
}

.fov-cone {
    fill: rgba(0, 102, 204, 0.2);
    stroke: var(--primary);
    stroke-width: 2;
}

/* =============================================================================
   Storage Panel
   ============================================================================= */

.storage-panel {
    background: var(--white);
    border-top: 1px solid var(--border);
    padding: 8px 16px;
    max-height: 150px;
    overflow-y: auto;
    transition: all 0.3s ease;
    font-size: 0.8rem;
}

.storage-panel.collapsed .storage-body {
    display: none;
}

.storage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.storage-header h3 {
    margin: 0;
    font-size: 0.85rem;
}

.btn-collapse {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--secondary);
    padding: 4px 8px;
    border-radius: var(--radius);
    transition: background 0.2s;
}

.btn-collapse:hover {
    background: var(--light);
}

.storage-config {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.config-item {
    flex: 1;
    min-width: 100px;
}

.config-item label {
    display: block;
    font-size: 0.7rem;
    color: var(--secondary);
    margin-bottom: 4px;
    font-weight: 600;
}

.config-item .form-control {
    padding: 4px 8px;
    font-size: 0.75rem;
}

.storage-results {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 8px;
}

.result-card {
    background: var(--light);
    border-radius: var(--radius);
    padding: 8px;
    text-align: center;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.result-card:hover {
    border-color: var(--primary);
}

.result-card.highlight {
    background: var(--primary);
    color: var(--white);
}

.result-value {
    font-size: 1.1rem;
    font-weight: 700;
}

.result-label {
    font-size: 0.65rem;
    opacity: 0.8;
    margin-top: 4px;
}

.storage-table-container {
    max-height: 80px;
    overflow-y: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.storage-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.storage-table th,
.storage-table td {
    padding: 4px 8px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.storage-table th {
    background: var(--light);
    font-weight: 600;
    position: sticky;
    top: 0;
}

.storage-table tbody tr:hover {
    background: var(--light);
}

/* =============================================================================
   Bandwidth Info (Sidebar Proprietà)
   ============================================================================= */

.bandwidth-info {
    background: var(--light);
    border-radius: var(--radius);
    padding: 12px;
    margin-top: 12px;
}

.bandwidth-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.bandwidth-row:last-child {
    border-bottom: none;
}

/* =============================================================================
   Camera Marker Improvements
   ============================================================================= */

.camera-marker {
    background: var(--primary);
    border: 3px solid var(--white);
    border-radius: 50%;
    width: 36px !important;
    height: 36px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
    cursor: move;
    transition: transform 0.2s, box-shadow 0.2s;
}

.camera-marker:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(0,0,0,0.4);
}

.camera-marker.selected {
    background: var(--warning);
    border-color: var(--dark);
    transform: scale(1.15);
}

/* Tooltip per telecamere sulla mappa */
.camera-tooltip {
    background: var(--dark);
    color: var(--white);
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 0.8rem;
    white-space: nowrap;
}

.camera-tooltip .model {
    font-weight: 600;
}

.camera-tooltip .specs {
    opacity: 0.8;
    font-size: 0.7rem;
}

/* =============================================================================
   Animations
   ============================================================================= */

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.camera-marker.new {
    animation: pulse 0.5s ease;
}

/* =============================================================================
   Responsive Design
   ============================================================================= */

@media (max-width: 1200px) {
    .storage-results {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .designer-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        max-height: 200px;
        overflow-y: auto;
    }
    
    .storage-results {
        grid-template-columns: 1fr 1fr;
    }
    
    .storage-config {
        flex-direction: column;
    }
    
    .storage-table {
        font-size: 0.75rem;
    }
    
    .storage-table th,
    .storage-table td {
        padding: 6px 8px;
    }
}

/* =============================================================================
   Dark Mode Support (opzionale)
   ============================================================================= */

@media (prefers-color-scheme: dark) {
    :root {
        --light: #1a1a2e;
        --dark: #eaeaea;
        --white: #16213e;
        --border: #0f3460;
    }
}
