/* style.css */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --light-color: #ecf0f1;
    --dark-color: #34495e;
    --offline-color: #95a5a6;
    --card-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
    --border-radius: 8px;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f7fa;
    color: var(--primary-color);
    line-height: 1.6;
    font-size: 16px;
    direction: rtl;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

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

header h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-color);
}

.last-update {
    font-size: 18px;
    color: var(--dark-color);
}

/* Dashboard Grid */
.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 5px;
}

/* Machine Card */
.machine-card {
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    padding: 25px;
    transition: var(--transition);
    cursor: pointer;
    min-height: 250px;
    display: flex;
    flex-direction: column;
}

.machine-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.machine-card.offline {
    background-color: #f1f1f1;
    color: var(--offline-color);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--light-color);
}

.machine-name {
    font-size: 24px;
    font-weight: 600;
}

.status-indicator {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: var(--success-color);
}

.status-indicator.below-threshold {
    background-color: var(--danger-color);
}

.status-indicator.offline {
    background-color: var(--offline-color);
}

.card-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.machine-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.status-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.online {
    background-color: var(--success-color);
    color: white;
}

.status-badge.offline {
    background-color: var(--offline-color);
    color: white;
}

.status-badge.active {
    background-color: var(--success-color);
    color: white;
}

.status-badge.inactive {
    background-color: var(--warning-color);
    color: white;
}

.data-item {
    margin-bottom: 15px;
}

.data-label {
    font-size: 18px;
    font-weight: 500;
    color: var(--dark-color);
    margin-bottom: 5px;
}

.data-value {
    font-size: 9em;
    font-weight: 700;
    line-height: 1em;
}

.data-value.below-threshold {
    color: var(--danger-color);
}

.data-value.offline {
    color: var(--offline-color);
}

.threshold-indicator {
    font-size: 16px;
    color: var(--dark-color);
}

.product-info {
    margin-top: auto;
    padding-top: 15px;
    border-top: 2px solid var(--light-color);
}

.product-label {
    font-size: 16px;
    font-weight: 500;
    color: var(--dark-color);
}

.product-value {
    font-size: 18px;
    font-weight: 600;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    overflow-y: auto;
}

.modal-content {
    position: relative;
    background-color: white;
    margin: 50px auto;
    padding: 30px;
    width: 90%;
    max-width: 1000px;
    border-radius: var(--border-radius);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 25px;
    font-size: 30px;
    cursor: pointer;
    color: var(--dark-color);
}

.modal h2 {
    font-size: 28px;
    margin-bottom: 25px;
    color: var(--primary-color);
}

/* Tabs */
.tabs {
    display: flex;
    margin-bottom: 25px;
    border-bottom: 2px solid var(--light-color);
}

.tab-btn {
    padding: 12px 25px;
    font-size: 18px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--dark-color);
    transition: var(--transition);
    border-bottom: 3px solid transparent;
    margin-right: 15px;
}

.tab-btn.active {
    color: var(--secondary-color);
    border-bottom: 3px solid var(--secondary-color);
    font-weight: 600;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Period Selector */
.period-selector {
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.period-selector label {
    font-size: 18px;
    font-weight: 500;
}

.period-selector select,
.period-selector input {
    padding: 10px 15px;
    font-size: 16px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    background-color: white;
}

.custom-date-range {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 15px;
    align-items: center;
}

/* Chart */
.chart-container {
    height: 400px;
    margin-bottom: 30px;
}

/* Production Summary */
.production-summary {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    background-color: var(--light-color);
    padding: 20px;
    border-radius: var(--border-radius);
    margin-top: 25px;
}

.summary-item {
    text-align: center;
    padding: 10px 20px;
}

.summary-item .label {
    font-size: 18px;
    font-weight: 500;
    color: var(--dark-color);
    display: block;
    margin-bottom: 5px;
}

.summary-item .value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-color);
    display: block;
}

/* Form Styling */
.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 10px;
    color: var(--dark-color);
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    font-size: 16px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    background-color: white;
}

.btn {
    padding: 12px 25px;
    font-size: 18px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

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

.primary-btn:hover {
    background-color: #2980b9;
}

/* Product History */
.product-history {
    margin-top: 40px;
}

.product-history h3 {
    font-size: 22px;
    margin-bottom: 20px;
    color: var(--primary-color);
}

.product-list {
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    overflow: hidden;
}

.product-item {
    padding: 15px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.product-item-name {
    font-size: 18px;
    font-weight: 500;
}

.product-item-date {
    font-size: 14px;
    color: var(--dark-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .dashboard {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        padding: 20px;
    }
    
    .tab-btn {
        padding: 10px 15px;
        font-size: 16px;
    }
    
    .data-value {
        font-size: 58px;
    }
    
    .summary-item .value {
        font-size: 24px;
    }
}

@media (max-width: 480px) {
    header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .last-update {
        margin-top: 10px;
    }
    
    .period-selector {
        flex-direction: column;
        align-items: flex-start;
    }
}