/* Electronic Components Manager Pro - Frontend Styles */

.ecm-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Toolbar */
.ecm-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.ecm-toolbar-left h2 {
    margin: 0;
    color: #333;
    font-size: 24px;
}

.ecm-toolbar-right {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.ecm-search-input {
    width: 250px;
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.ecm-search-input:focus {
    outline: none;
    border-color: #0073aa;
}

/* Buttons */
.ecm-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    white-space: nowrap;
}

.ecm-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.ecm-btn-primary {
    background: linear-gradient(135deg, #0073aa 0%, #005a87 100%);
    color: white;
}

.ecm-btn-secondary {
    background: linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 100%);
    color: #333;
}

.ecm-btn-danger {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
}

.ecm-btn-cancel {
    background: #6c757d;
    color: white;
}

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

.ecm-btn-group {
    display: flex;
    gap: 8px;
}

.ecm-icon {
    font-size: 16px;
}

/* Select */
.ecm-select {
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    min-width: 180px;
}

.ecm-select:focus {
    outline: none;
    border-color: #0073aa;
}

/* Tabella */
.ecm-table-wrapper {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow: hidden;
}

.ecm-table {
    width: 100%;
    border-collapse: collapse;
}

.ecm-table thead {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
}

.ecm-table thead th {
    padding: 15px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ecm-table tbody tr {
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s;
}

.ecm-table tbody tr:hover {
    background-color: #f8f9fa;
}

.ecm-table tbody td {
    padding: 12px;
    font-size: 14px;
}

.ecm-table tbody td.ecm-loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.ecm-component-img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
}

.ecm-no-image {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    border-radius: 4px;
    color: #999;
    font-size: 20px;
}

.ecm-qty-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 13px;
}

.ecm-qty-normal {
    background: #d4edda;
    color: #155724;
}

.ecm-qty-low {
    background: #fff3cd;
    color: #856404;
}

.ecm-qty-critical {
    background: #f8d7da;
    color: #721c24;
}

.ecm-actions-cell {
    white-space: nowrap;
}

/* Modal */
.ecm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.ecm-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    z-index: 9999;
}

.ecm-modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 10001;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.ecm-modal-large {
    max-width: 1000px;
}

.ecm-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 2px solid #e0e0e0;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.ecm-modal-header h3 {
    margin: 0;
    color: #333;
    font-size: 20px;
}

.ecm-modal-close,
.ecm-modal-close-labels {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    transition: color 0.2s;
}

.ecm-modal-close:hover,
.ecm-modal-close-labels:hover {
    color: #333;
}

.ecm-modal-body {
    padding: 25px;
}

.ecm-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px 25px;
    border-top: 2px solid #e0e0e0;
    background: #f8f9fa;
}

/* Form */
.ecm-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    padding: 25px;
}

.ecm-form-column h4 {
    margin: 0 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
    color: #2c3e50;
    font-size: 16px;
}

.ecm-form-group {
    margin-bottom: 20px;
}

.ecm-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.ecm-form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #333;
    font-size: 13px;
}

.ecm-input,
.ecm-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.3s;
}

.ecm-input:focus,
.ecm-textarea:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0,115,170,0.1);
}

.ecm-hint {
    color: #666;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

/* Image Upload */
.ecm-image-upload {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ecm-preview-area {
    width: 100%;
    height: 180px;
    border: 2px dashed #ddd;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: #f9f9f9;
}

.ecm-preview-area p {
    margin: 0;
    color: #999;
}

.ecm-preview-area img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Files List */
.ecm-files-list {
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    padding: 12px;
    min-height: 80px;
    margin-bottom: 10px;
    background: #fafafa;
}

.ecm-file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    margin-bottom: 8px;
    background-color: white;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.ecm-file-item:last-child {
    margin-bottom: 0;
}

.ecm-file-name {
    flex: 1;
    font-size: 13px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ecm-file-remove {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    font-size: 18px;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.ecm-file-remove:hover {
    color: #c82333;
}

.ecm-files-list:empty::before {
    content: "Nessun datasheet aggiunto";
    color: #999;
    font-size: 13px;
    font-style: italic;
}

/* Etichette */
.ecm-labels-preview {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    min-height: 300px;
    background: white;
    margin-top: 15px;
}

.ecm-label {
    border: 1px solid #333;
    padding: 8px;
    text-align: center;
    font-size: 10px;
    background: white;
}

.ecm-label-name {
    font-weight: bold;
    font-size: 11px;
    margin-bottom: 4px;
}

.ecm-label-pn {
    font-size: 9px;
    color: #666;
    margin-bottom: 4px;
}

.ecm-label-barcode {
    height: 30px;
    margin: 4px 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ecm-label-barcode img {
    max-width: 100%;
    height: 100%;
}

.ecm-label-footer {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid #ddd;
}

/* DataTables overrides */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    display: none;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    padding: 15px;
}

/* Responsive */
@media (max-width: 1024px) {
    .ecm-form-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .ecm-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .ecm-toolbar-right {
        flex-direction: column;
        width: 100%;
    }
    
    .ecm-search-input,
    .ecm-select {
        width: 100%;
    }
    
    .ecm-table {
        font-size: 12px;
    }
    
    .ecm-table thead th,
    .ecm-table tbody td {
        padding: 8px 6px;
    }
    
    .ecm-form-row {
        grid-template-columns: 1fr;
    }
}

/* Animazioni */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.ecm-modal-content {
    animation: fadeIn 0.3s ease;
}

/* Print styles per etichette */
@media print {
    body * {
        visibility: hidden;
    }
    
    .ecm-labels-preview,
    .ecm-labels-preview * {
        visibility: visible;
    }
    
    .ecm-labels-preview {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }
}
