/* =========================================================
   استایل اتوماسیون اداری
   ========================================================= */

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

body {
    font-family: Tahoma, 'Segoe UI', Arial, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    padding: 15px;
    color: #2c3e50;
    line-height: 1.6;
}

.automation-container {
    max-width: 1100px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    overflow: hidden;
    padding: 25px;
}

/* =========================================================
   هدر (مشابه سایر بخش‌ها)
   ========================================================= */
.main-header {
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    color: white;
    padding: 15px 20px 12px;
    border-radius: 12px;
    margin-bottom: 20px;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.main-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 50%, rgba(255,255,255,0.05), transparent 60%);
    pointer-events: none;
}
.main-header h1 {
    font-size: 24px;
    margin: 0 0 4px 0;
    font-weight: 700;
    position: relative;
    z-index: 1;
}
.main-header .subtitle {
    font-size: 14px;
    font-weight: 400;
    opacity: 0.85;
    margin: 0 0 10px 0;
    position: relative;
    z-index: 1;
}


/* =========================================================
   نوار کاربر
   ========================================================= */
.user-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: linear-gradient(135deg, #eaf4fb, #d6eaf8);
    border-radius: 10px;
    margin-bottom: 20px;
    border: 1px solid #bee5eb;
    flex-wrap: wrap;
    gap: 10px;
}
.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.user-greeting {
    font-size: 14px;
    color: #2c3e50;
}
.user-greeting strong {
    color: #0c5460;
    font-size: 15px;
}
.user-role {
    font-size: 11px;
    padding: 3px 12px;
    background: #ffc107;
    color: #856404;
    border-radius: 20px;
    font-weight: 700;
}
.logout-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: Tahoma;
    transition: all 0.3s;
}
.logout-btn:hover {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(220, 53, 69, 0.3);
}

/* =========================================================
   کارت‌های آماری (در صورت نیاز)
   ========================================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}
.stat-card {
    background: white;
    border-radius: 12px;
    padding: 18px 15px;
    text-align: center;
    border: 2px solid #e9ecef;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}
.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}
.stat-card .stat-icon {
    font-size: 28px;
    margin-bottom: 6px;
}
.stat-card .stat-number {
    font-size: 30px;
    font-weight: 800;
    color: #2c3e50;
    line-height: 1.2;
}
.stat-card .stat-label {
    font-size: 13px;
    color: #7f8c8d;
    margin-top: 5px;
    font-weight: 600;
}
.stat-card.stat-new { border-color: #3498db; }
.stat-card.stat-new:hover { background: #eaf4fb; }
.stat-card.stat-new .stat-number { color: #3498db; }
.stat-card.stat-in-action { border-color: #f39c12; }
.stat-card.stat-in-action:hover { background: #fff9e6; }
.stat-card.stat-in-action .stat-number { color: #f39c12; }
.stat-card.stat-completed { border-color: #28a745; }
.stat-card.stat-completed:hover { background: #e8f8ed; }
.stat-card.stat-completed .stat-number { color: #28a745; }
.stat-card.stat-sent { border-color: #8e44ad; }
.stat-card.stat-sent:hover { background: #f3e8fa; }
.stat-card.stat-sent .stat-number { color: #8e44ad; }

/* =========================================================
   منوی اتوماسیون
   ========================================================= */
.menu-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin-bottom: 25px;
}
.menu-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 22px;
    border: none;
    border-radius: 14px;
    font-family: Tahoma, 'Segoe UI', Arial, sans-serif;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    text-decoration: none;
    color: white;
    position: relative;
    overflow: hidden;
    min-height: 80px;
}
.menu-btn .icon { 
    font-size: 32px; 
    flex-shrink: 0; 
}
.menu-btn .label {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.35;
    flex: 1;
    text-align: right;
}
.menu-btn .label .sub {
    font-size: 12px;
    font-weight: 400;
    opacity: 0.85;
    margin-top: 3px;
}
.menu-btn .badge-count {
    position: absolute;
    top: 12px;
    left: 12px;
    background: #ffc107;
    color: #856404;
    font-size: 11px;
    font-weight: 800;
    padding: 2px 10px;
    border-radius: 20px;
    min-width: 24px;
    text-align: center;
}
.menu-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}
.menu-btn:active {
    transform: translateY(0px) scale(0.98);
}

/* ===== رنگ‌بندی دکمه‌های منو ===== */
.btn-new-message { background: linear-gradient(135deg, #0f9b58 0%, #22c55e 100%); }
.btn-inbox { background: linear-gradient(135deg, #1e3a5f 0%, #2c7be5 100%); }
.btn-sent { background: linear-gradient(135deg, #8e44ad 0%, #c471ed 100%); }
.btn-unread { background: linear-gradient(135deg, #f39c12 0%, #fbbf24 100%); }
.btn-urgent { background: linear-gradient(135deg, #e11d48 0%, #fb7185 100%); }
.btn-notifications { background: linear-gradient(135deg, #475569 0%, #94a3b8 100%); }

/* =========================================================
   بخش پیام‌های اخیر
   ========================================================= */
.recent-section {
    margin-bottom: 25px;
}
.section-title {
    font-size: 17px;
    color: #2c3e50;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e9ecef;
    font-weight: 700;
}

/* =========================================================
   کارت پیام
   ========================================================= */
.message-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.message-card {
    background: white;
    border-radius: 10px;
    padding: 14px 18px;
    border: 1px solid #e9ecef;
    border-right: 4px solid #3498db;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    color: inherit;
    display: block;
}
.message-card:hover {
    transform: translateX(-3px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}
.message-card.importance-urgent { border-right-color: #f39c12; }
.message-card.importance-very_urgent { border-right-color: #e74c3c; }
.message-card.importance-instant { border-right-color: #c0392b; background: #fdf2f2; }

/* ===== پیام‌های خوانده‌نشده ===== */
.message-card.unread {
    background: linear-gradient(135deg, #eaf4fb 0%, #d6eaf8 100%);
    border-right-width: 6px;
    border-right-color: #2c7be5;
    font-weight: 700;
    box-shadow: 0 3px 12px rgba(52, 152, 219, 0.15);
}
.message-card.unread .msg-title {
    font-size: 16px;
    font-weight: 800;
    color: #0c5460;
}
.message-card.unread .msg-preview {
    color: #2c3e50;
    font-weight: 600;
}

/* ===== پیام‌های خوانده‌شده ===== */
.message-card:not(.unread) {
    background: #ffffff;
    opacity: 0.85;
}
.message-card:not(.unread) .msg-title {
    font-size: 14px;
    font-weight: 600;
    color: #495057;
}
.message-card:not(.unread) .msg-preview {
    color: #7f8c8d;
    font-weight: 400;
}

.message-card .msg-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 6px;
}
.message-card .msg-title {
    flex: 1;
    min-width: 150px;
}
.message-card .msg-badges {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}
.message-card .msg-badge {
    font-size: 10px;
    padding: 2px 9px;
    border-radius: 20px;
    font-weight: 700;
    white-space: nowrap;
}
.badge-importance-normal { background: #e9ecef; color: #495057; }
.badge-importance-urgent { background: #fff3cd; color: #856404; }
.badge-importance-very_urgent { background: #f8d7da; color: #721c24; }
.badge-importance-instant { background: #c0392b; color: white; }
.badge-tracking { background: #d1ecf1; color: #0c5460; font-family: 'Courier New', monospace; }
.badge-status-new { background: #d1ecf1; color: #0c5460; }
.badge-status-pending { background: #fff3cd; color: #856404; }
.badge-status-in_review { background: #e7f3ff; color: #0056b3; }
.badge-status-in_action { background: #fff0e1; color: #d97706; }
.badge-status-completed { background: #d4edda; color: #155724; }

.message-card .msg-meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: #7f8c8d;
    flex-wrap: wrap;
    margin-top: 6px;
}
.message-card .msg-preview {
    font-size: 13px;
    color: #6c757d;
    margin-top: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* =========================================================
   دکمه‌ها
   ========================================================= */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-family: Tahoma;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 600;
}
.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}
.btn-primary { background: #3498db; color: white; }
.btn-primary:hover { background: #2980b9; }
.btn-success { background: #28a745; color: white; }
.btn-success:hover { background: #218838; }
.btn-danger { background: #dc3545; color: white; }
.btn-danger:hover { background: #c82333; }
.btn-warning { background: #ffc107; color: #2c3e50; }
.btn-warning:hover { background: #e0a800; }
.btn-secondary { background: #95a5a6; color: white; }
.btn-secondary:hover { background: #7f8c8d; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; }

/* =========================================================
   فرم‌ها
   ========================================================= */
.form-group { margin-bottom: 15px; }
.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
}
.form-group label .required { color: #dc3545; }
.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-family: Tahoma;
    font-size: 14px;
    transition: border 0.3s;
    box-sizing: border-box;
    background: white;
}
.form-control:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 3px rgba(52,152,219,0.15);
}
textarea.form-control {
    min-height: 140px;
    resize: vertical;
    line-height: 1.7;
}
select.form-control {
    appearance: auto;
    cursor: pointer;
}

.password-wrapper { position: relative; }
.password-toggle {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #7f8c8d;
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
}
.password-toggle:hover { color: #2c3e50; }

/* =========================================================
   نوتیفیکیشن
   ========================================================= */
.notification {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    display: none;
    font-weight: 600;
    font-size: 13px;
}
.notification.success {
    display: block;
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.notification.error {
    display: block;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}
.notification.info {
    display: block;
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}
.notification.warning {
    display: block;
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
}

/* =========================================================
   لودر
   ========================================================= */
.loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #7f8c8d;
}
.loader-container .spinner {
    width: 36px;
    height: 36px;
    border: 4px solid rgba(52,152,219,0.15);
    border-top-color: #3498db;
    border-radius: 50%;
    animation: spin 0.8s ease-in-out infinite;
    margin-bottom: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s ease-in-out infinite;
}

/* =========================================================
   Empty State
   ========================================================= */
.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: #7f8c8d;
}
.empty-state .icon {
    font-size: 50px;
    margin-bottom: 12px;
}
.empty-state h3 {
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 17px;
}
.empty-state p {
    font-size: 13px;
}

/* =========================================================
   فوتر
   ========================================================= */
.main-footer {
    background: linear-gradient(135deg, #1e3a5f 0%, #2c7be5 100%);
    color: white;
    padding: 25px 20px 12px;
    margin-top: 30px;
    border-radius: 12px;
}
.footer-content {
    max-width: 1100px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
}
.footer-section {
    background: rgba(255,255,255,0.08);
    padding: 15px 18px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.12);
}
.footer-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 10px;
    color: #ffd700;
    padding-bottom: 6px;
    border-bottom: 2px solid rgba(255,215,0,0.3);
}
.footer-about {
    font-size: 12px;
    line-height: 1.8;
    color: rgba(255,255,255,0.9);
    text-align: justify;
}
.footer-contact-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 12px;
    color: rgba(255,255,255,0.9);
    margin-bottom: 8px;
    line-height: 1.7;
}
.footer-icon { font-size: 16px; flex-shrink: 0; }
.footer-map iframe {
    width: 100%;
    height: 160px;
    border-radius: 8px;
    border: 2px solid rgba(255,255,255,0.15);
}
.footer-bottom {
    text-align: center;
    margin-top: 20px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.15);
    font-size: 11px;
    color: rgba(255,255,255,0.7);
}

/* =========================================================
   ریسپانسیو
   ========================================================= */
@media (max-width: 768px) {
    body { padding: 8px; }
    .automation-container { padding: 15px; border-radius: 10px; }
    .main-header h1 { font-size: 20px; }
    .main-header .subtitle { font-size: 12px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 14px 10px; }
    .stat-card .stat-number { font-size: 24px; }
    .stat-card .stat-icon { font-size: 22px; }
    .stat-card .stat-label { font-size: 11px; }
    .menu-grid { grid-template-columns: 1fr; gap: 10px; }
    .menu-btn { font-size: 14px; padding: 16px 18px; min-height: 70px; }
    .menu-btn .icon { font-size: 26px; }
    .user-bar { padding: 10px 14px; }
    .user-greeting { font-size: 13px; }
    .logout-btn { padding: 6px 14px; font-size: 12px; }
    .message-card { padding: 12px 14px; }
    .footer-content { grid-template-columns: 1fr; gap: 12px; }
    .footer-map iframe { height: 180px; }
}

@media (max-width: 480px) {
    body { padding: 5px; }
    .automation-container { padding: 10px; }
    .main-header { padding: 12px 14px 10px; }
    .main-header h1 { font-size: 17px; }
    .main-header .subtitle { font-size: 11px; }
    .main-header .back-link { font-size: 12px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .stat-card .stat-number { font-size: 20px; }
    .stat-card .stat-icon { font-size: 20px; }
    .user-greeting { font-size: 12px; }
    .user-role { font-size: 10px; padding: 2px 8px; }
    .logout-btn { padding: 5px 12px; font-size: 11px; }
    .menu-btn { font-size: 13px; padding: 14px 16px; min-height: 65px; }
    .menu-btn .icon { font-size: 24px; }
    .section-title { font-size: 14px; }
    .message-card .msg-title { font-size: 13px; }
    .message-card .msg-badge { font-size: 9px; padding: 2px 6px; }
    .message-card .msg-meta { font-size: 10px; gap: 8px; }
    .message-card.unread .msg-title { font-size: 15px; }
}
/* ===== دکمه بازگشت ===== */
.back-link {
    display: inline-block;
    margin: 9px auto 15px;
    padding: 7px 21px;
    background: linear-gradient(135deg, #d4af37, #b8860b);
    color: #ffffff;
    text-decoration: none;
    font-size: 12px;
    font-weight: bold;
    border: 1px solid #f1d675;
    border-radius: 10px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.18);
    transition: all 0.25s ease;
    cursor: pointer;
}

.back-link:hover {
    background: linear-gradient(135deg, #e5c454, #c99a16);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.22);
}

.back-link:active {
    transform: translateY(0);
}
