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

body {
    font-family: 'Tahoma', 'Arial', sans-serif;
    background: #f5f5f5;
    line-height: 1.6;
    font-size: 14px;
}

/* مدیریت صفحات */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* صفحه ورود */
#loginPage {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    width: 400px;
    text-align: center;
}

.login-container h1 {
    margin-bottom: 2rem;
    color: #333;
    font-size: 1.5rem;
}

#loginForm input {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    text-align: center;
    transition: border-color 0.3s;
}

#loginForm input:focus {
    border-color: #4CAF50;
    outline: none;
}

#loginForm button {
    width: 100%;
    padding: 12px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    margin-top: 10px;
    transition: background 0.3s;
}

#loginForm button:hover {
    background: #45a049;
}

#loginForm button:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

/* صفحه اصلی */
#mainPage {
    padding: 15px;
    min-height: 100vh;
}

header {
    background: #2c3e50;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 1.4rem;
    margin: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* دکمه‌ها */
.btn-primary {
    background: #3498db;
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s;
}

.btn-danger {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s;
}

.btn-primary:hover { background: #2980b9; transform: translateY(-1px); }
.btn-secondary:hover { background: #7f8c8d; transform: translateY(-1px); }
.btn-danger:hover { background: #c0392b; transform: translateY(-1px); }

.controls {
    margin-bottom: 15px;
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.role-badge {
    background: #9b59b6;
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
}

/* جدول */
.table-container {
    overflow-x: auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    max-height: 75vh;
    margin-bottom: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1800px;
    font-size: 12px;
}

th, td {
    border: 1px solid #e1e1e1;
    padding: 8px 6px;
    text-align: center;
    vertical-align: middle;
    height: 40px;
}

/* هدر جدول */
.header-row th {
    background: #34495e;
    color: white;
    font-weight: bold;
    position: sticky;
    top: 0;
    z-index: 10;
    white-space: nowrap;
    font-size: 11px;
}

.main-header th {
    background: #2c3e50;
    font-size: 12px;
}

.sub-header th {
    background: #34495e;
    font-size: 11px;
}

/* بدنه جدول */
tbody tr {
    transition: background 0.2s;
}

tbody tr:nth-child(even) {
    background: #f9f9f9;
}

tbody tr:hover {
    background: #f0f8ff;
}

/* وضعیت‌های ردیف */
.status-completed {
    background: #d4edda !important;
}

.status-control-pending {
    background: #fff3cd !important;
}

.status-control-inprogress {
    background: #ffe6cc !important;
}

.status-supervisor-pending {
    background: #e6f3ff !important;
}

.status-correction {
    background: #f8d7da !important;
}

.status-urgent {
    background: #ffcccc !important;
    animation: pulse 2s infinite;
}

.status-warning {
    background: #fff3cd !important;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.8; }
    100% { opacity: 1; }
}

/* سلول‌های قابل ویرایش */
.editable {
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.editable:hover {
    background: #e3f2fd !important;
    border: 1px solid #3498db !important;
}

/* چک‌باکس */
.checkbox-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.checkbox-cell {
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.checkbox-input {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #4CAF50;
    transform: scale(1.1);
}

/* رنگ‌بندی براساس کاربر */
.cell-mapper { 
    background: #f0f8f0 !important;
    border-left: 3px solid #4CAF50 !important;
}

.cell-controller { 
    background: #fff8f0 !important;
    border-left: 3px solid #FF9800 !important;
}

.cell-admin { 
    background: #fff0f0 !important;
    border-left: 3px solid #f44336 !important;
}

/* دکمه حذف */
.delete-btn {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s;
}

.delete-btn:hover {
    background: #c0392b;
    transform: scale(1.05);
}

/* مودال‌ها */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: #fefefe;
    padding: 25px;
    border-radius: 10px;
    width: 450px;
    position: relative;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h3 {
    margin-bottom: 20px;
    text-align: center;
    color: #2c3e50;
    font-size: 1.3rem;
}

.close {
    color: #aaa;
    position: absolute;
    left: 15px;
    top: 10px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

.close:hover {
    color: black;
}

/* فرم */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: bold;
    color: #2c3e50;
    font-size: 13px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    border-color: #3498db;
    outline: none;
}

.user-select {
    background: white;
}

.user-select option {
    padding: 8px;
    font-size: 14px;
}

.form-buttons {
    display: flex;
    gap: 10px;
    margin-top: 25px;
}

.form-buttons button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

/* پیام‌ها */
.message {
    margin-top: 12px;
    padding: 12px 15px;
    border-radius: 6px;
    text-align: center;
    font-size: 13px;
    display: none;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

.message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
    display: block;
}

/* استایل برای سلول‌های تاریخ */
.date-cell {
    cursor: pointer;
    color: #2c3e50;
    font-weight: 500;
    transition: all 0.2s;
}

.date-cell:hover {
    background: #3498db !important;
    color: white;
    transform: scale(1.02);
}

/* استایل برای سلول‌های متنی */
.text-cell {
    min-width: 80px;
    padding: 6px 8px;
}

.text-cell:focus {
    outline: 2px solid #3498db;
    background: white !important;
}

/* وضعیت خالی */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-style: italic;
    background: #f9f9f9;
    border-radius: 8px;
    margin: 20px 0;
}

/* پاسخگویی */
@media (max-width: 768px) {
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .controls button {
        width: 100%;
    }
    
    .user-info {
        flex-wrap: wrap;
    }
    
    .modal-content {
        width: 95%;
        margin: 10px;
    }
}