/* Dashboard Responsive CSS */

/* Variabili colore per tema beige/grigio elegante */
:root {
    --primary-color: #8b8680;
    --secondary-color: #a19b95;
    --success-color: #7c8471;
    --warning-color: #b8956d;
    --danger-color: #b87c6d;
    --info-color: #7d8b8b;
    --light-color: #f7f5f3;
    --dark-color: #5c5952;
    --background-color: #e8e6e1;
    --card-background: #ffffff;
    --text-primary: #4a453f;
    --text-secondary: #6b6760;
    --border-color: #d7d5d0;
    --card-shadow: 0 2px 8px rgba(139, 134, 128, 0.15);
    --border-radius: 8px;
}

/* Reset e base styles */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Layout principale */
.main-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header responsivo */
.dashboard-header {
    background: linear-gradient(135deg, var(--primary-color), var(--dark-color));
    color: var(--light-color);
    padding: 1rem 1.5rem;
    box-shadow: var(--card-shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.dashboard-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

/* Contenuto principale */
.dashboard-content {
    flex: 1;
    padding: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Per la dashboard principale con 6 card, usiamo un layout specifico */
.dashboard-main-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (min-width: 1400px) {
    .dashboard-main-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (min-width: 1200px) and (max-width: 1399px) {
    .dashboard-main-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .dashboard-main-grid {
        grid-template-columns: 1fr;
    }
}

/* Card base */
.dashboard-card {
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    padding: 1.5rem;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.dashboard-card:hover {
    box-shadow: 0 4px 16px rgba(139, 134, 128, 0.25);
    transform: translateY(-2px);
}

/* Stili per i filtri macchina */
.filter-card {
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

.filter-card:hover {
    background: var(--light-color);
    border-color: var(--primary-color);
}

.filter-card.active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-color: var(--primary-color);
    color: white;
}

.filter-card.active .filter-label,
.filter-card.active .filter-count {
    color: white !important;
}

/* Card header */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--light-color);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dark-color);
    margin: 0;
}

.card-icon {
    font-size: 1.5rem;
    color: var(--primary-color);
}

/* Statistiche */
.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0.5rem 0;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.stat-change {
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

.stat-change.positive {
    color: var(--success-color);
}

.stat-change.negative {
    color: var(--danger-color);
}

/* Chart container */
.chart-container {
    height: 300px;
    margin-top: 1rem;
    position: relative;
}

/* Progress bars */
.progress-container {
    margin: 1rem 0;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.progress {
    height: 8px;
    background-color: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--dark-color));
    transition: width 0.6s ease;
}

/* Lista attività */
.activity-list {
    max-height: 400px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #f8f9fa;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 1rem;
    font-size: 1.2rem;
    color: white;
}

.activity-content {
    flex: 1;
}

.activity-title {
    font-weight: 600;
    color: var(--dark-color);
    margin: 0 0 0.25rem 0;
}

.activity-time {
    font-size: 0.8rem;
    color: var(--secondary-color);
    margin: 0;
}

/* Pulsanti responsive */
.btn-dashboard {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-dashboard:hover {
    background: #0052a3;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Pulsanti filtro - Stile moderno come btn-dashboard */
.btn-filter {
    background: #6c757d;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 38px;
}

.btn-filter:hover {
    background: #5a6268;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    color: white;
}

.btn-filter.active {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

.btn-filter.active:hover {
    background: #0052a3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.4);
    color: white;
}

.btn-filter:focus {
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.btn-filter:active {
    transform: translateY(0);
}

/* Contenitore filtri */
.filter-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 0.5rem;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Gap per i pulsanti filtro */
.filter-bar .d-flex {
    gap: 0.75rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .dashboard-content {
        padding: 1rem;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .dashboard-card {
        padding: 1rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .dashboard-header {
        padding: 0.75rem 1rem;
    }
    
    .dashboard-title {
        font-size: 1.25rem;
    }
    
    .chart-container {
        height: 250px;
    }
    
    .filter-bar {
        padding: 0.75rem;
        margin-bottom: 1.5rem;
    }
    
    .filter-bar .d-flex {
        flex-wrap: wrap;
        gap: 0.5rem;
        width: 100%;
        justify-content: center;
    }
    
    .btn-filter {
        flex: 1;
        min-width: 100px;
        max-width: 140px;
        justify-content: center;
        font-size: 0.8rem;
        padding: 0.6rem 1rem;
    }
}

@media (max-width: 576px) {
    .filter-bar .d-flex {
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }
    
    .btn-filter {
        width: 100%;
        max-width: none;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .dashboard-content {
        padding: 0.75rem;
    }
    
    .dashboard-card {
        padding: 0.75rem;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .stat-value {
        font-size: 1.25rem;
    }
    
    .chart-container {
        height: 200px;
    }
}

/* Animazioni */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.6s ease-out;
}

/* Utilities */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--secondary-color) !important;
}

.mb-0 {
    margin-bottom: 0 !important;
}

.mt-3 {
    margin-top: 1rem !important;
}

.d-flex {
    display: flex !important;
}

.justify-content-between {
    justify-content: space-between !important;
}

.align-items-center {
    align-items: center !important;
}

/* Stili per telai */
.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.status-indicator.online {
    background-color: var(--success-color);
    box-shadow: 0 0 8px var(--success-color);
    animation: pulse-green 2s infinite;
}

.status-indicator.offline {
    background-color: var(--danger-color);
    animation: pulse-red 2s infinite;
}

@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(40, 167, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0); }
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(220, 53, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
}

.telaio-card {
    border-left: 4px solid var(--primary-color);
}

.telaio-status {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0.5rem 0;
    padding: 0.25rem 0;
    border-bottom: 1px solid #f8f9fa;
}

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

.info-label {
    font-weight: 500;
    color: var(--secondary-color);
}

.info-value {
    font-weight: 600;
}

.mini-telaio-card {
    background: white;
    padding: 0.75rem;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    transition: transform 0.2s ease;
}

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

.loading-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Loading spinner per telai */
.loading-spinner-large {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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

/* Stili per tabella ordini */
.table-responsive {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.table {
    margin-bottom: 0;
}

.table thead th {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
    border: none;
    padding: 1rem 0.75rem;
    font-size: 0.9rem;
}

.table tbody tr {
    transition: background-color 0.2s ease;
}

.table tbody tr:hover {
    background-color: rgba(0, 123, 255, 0.05);
}

.table tbody td {
    padding: 0.75rem;
    vertical-align: middle;
    border-top: 1px solid #e9ecef;
}

.badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 500;
}

/* Stili per progress bar in tabella */
.progress {
    height: 8px;
    background-color: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Modal personalizzato */
.modal-content {
    border-radius: 12px;
    border: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.modal-header {
    background-color: var(--primary-color);
    color: white;
    border-radius: 12px 12px 0 0;
    border-bottom: none;
}

.modal-header .btn-close {
    filter: invert(1);
}

.modal-body {
    padding: 2rem;
}

.modal-body h6 {
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 1rem;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 0.5rem;
}

/* Responsive design per tabelle ordini */
@media (max-width: 768px) {
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .table thead th {
        padding: 0.75rem 0.5rem;
        font-size: 0.8rem;
    }
    
    .table tbody td {
        padding: 0.5rem;
        font-size: 0.875rem;
    }
    
    .badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }
    
    .progress {
        height: 18px;
    }
    
    .progress-bar {
        font-size: 0.75rem;
    }
}

@media (max-width: 576px) {
    /* Stack delle statistiche su mobile */
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem;
    }
    
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        min-width: 800px;
    }
    
    .table thead th {
        white-space: nowrap;
        padding: 0.5rem 0.25rem;
        font-size: 0.75rem;
    }
    
    .table tbody td {
        padding: 0.5rem 0.25rem;
        font-size: 0.8rem;
    }
    
    .badge {
        font-size: 0.65rem;
        padding: 0.15rem 0.3rem;
    }
    
    .progress {
        height: 16px;
        min-width: 80px;
    }
    
    .progress-bar {
        font-size: 0.7rem;
    }
} 