/* ============================================================
   app.css — نظام الاتصالات الإدارية والأرشفة الإلكترونية
   Laravel RTL Dashboard · Bootstrap 5 RTL · Cairo Font
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
    --primary:        #1a56db;
    --primary-dark:   #1145b5;
    --primary-soft:   #e8f0fe;
    --success:        #0e9f6e;
    --success-soft:   #def7ec;
    --warning:        #c27803;
    --warning-soft:   #fdf6b2;
    --danger:         #e02424;
    --danger-soft:    #fde8e8;
    --info:           #0694a2;
    --info-soft:      #e0f7fa;
    --secondary:      #6b7280;
    --secondary-soft: #f3f4f6;

    --sidebar-width:        260px;
    --sidebar-collapsed-w:  68px;
    --topbar-height:        60px;
    --footer-height:        48px;

    --bg-body:     #f4f6fb;
    --bg-card:     #ffffff;
    --border-color:#e5e7eb;
    --text-main:   #111827;
    --text-muted:  #6b7280;
    --text-light:  #9ca3af;

    --radius-sm:  6px;
    --radius-md:  10px;
    --radius-lg:  14px;
    --shadow-sm:  0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
    --shadow-md:  0 4px 12px rgba(0,0,0,.08);
    --shadow-lg:  0 10px 30px rgba(0,0,0,.10);

    --transition: .22s ease;
}

/* ── Base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 14px; }

body {
    font-family: 'Cairo', 'Segoe UI', sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    direction: rtl;
    min-height: 100vh;
    overflow-x: hidden;
}

a { text-decoration: none; color: var(--primary); }
a:hover { color: var(--primary-dark); }

/* ── Layout Shell ───────────────────────────────────────────── */
.main-wrapper {
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-right var(--transition);
}

body.sidebar-collapsed .main-wrapper {
    margin-right: var(--sidebar-collapsed-w);
}

body.sidebar-mobile-open .sidebar-overlay {
    display: block;
}

/* ── Page Content ───────────────────────────────────────────── */
.page-content {
    flex: 1;
    padding-top: var(--topbar-height);
    padding-bottom: var(--footer-height);
    min-height: calc(100vh - var(--topbar-height) - var(--footer-height));
}

/* ── Page Header ────────────────────────────────────────────── */
.page-header {
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.page-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
}

.breadcrumb { font-size: .8rem; }
.breadcrumb-item a { color: var(--text-muted); }
.breadcrumb-item.active { color: var(--text-light); }
.breadcrumb-item + .breadcrumb-item::before { color: var(--text-light); }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    background: var(--bg-card);
}

.card-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: .85rem 1.1rem;
    border-radius: var(--radius-md) var(--radius-md) 0 0 !important;
}

.card-title { font-size: .9rem; font-weight: 600; color: var(--text-main); }

.card-footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: .6rem 1rem;
}

/* ── KPI Stat Cards ─────────────────────────────────────────── */
.stat-card {
    border-radius: var(--radius-md);
    padding: 1.2rem 1.4rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    transition: box-shadow var(--transition), transform var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-icon {
    width: 52px; height: 52px;
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-icon-primary   { background: var(--primary-soft);   color: var(--primary); }
.stat-icon-success   { background: var(--success-soft);   color: var(--success); }
.stat-icon-warning   { background: var(--warning-soft);   color: var(--warning); }
.stat-icon-danger    { background: var(--danger-soft);    color: var(--danger); }
.stat-icon-info      { background: var(--info-soft);      color: var(--info); }
.stat-icon-secondary { background: var(--secondary-soft); color: var(--secondary); }

.stat-label {
    font-size: .78rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: .15rem;
}

.stat-value {
    font-size: 1.7rem;
    font-weight: 800;
    line-height: 1;
    color: var(--text-main);
}

.stat-change {
    font-size: .75rem;
    margin-top: .2rem;
    font-weight: 500;
}

.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ── Mini Stat Cards (used in sub-pages) ───────────────────── */
.mini-stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: .8rem 1rem;
    display: flex;
    flex-direction: column;
    gap: .2rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.mini-stat-label { font-size: .75rem; color: var(--text-muted); font-weight: 500; }
.mini-stat-value { font-size: 1.5rem; font-weight: 800; line-height: 1; }

/* ── Status Badges ──────────────────────────────────────────── */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: .2rem .6rem;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-badge::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    margin-left: .35rem;
    flex-shrink: 0;
}

.status-processing { background: #e0f2fe; color: #0369a1; }
.status-processing::before { background: #0369a1; }

.status-pending    { background: #fef9c3; color: #854d0e; }
.status-pending::before { background: #ca8a04; }

.status-done       { background: var(--success-soft); color: #065f46; }
.status-done::before { background: var(--success); }

.status-overdue    { background: var(--danger-soft); color: #991b1b; }
.status-overdue::before { background: var(--danger); }

.status-draft      { background: #f3f4f6; color: #374151; }
.status-draft::before { background: #9ca3af; }

.status-approved   { background: #d1fae5; color: #065f46; }
.status-approved::before { background: #059669; }

.status-registered { background: #ede9fe; color: #5b21b6; }
.status-registered::before { background: #7c3aed; }

/* ── Priority Badges ────────────────────────────────────────── */
.priority-badge {
    display: inline-flex;
    align-items: center;
    padding: .18rem .55rem;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
}

.priority-very-urgent { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.priority-urgent      { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.priority-normal      { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }

/* ── Confidentiality Badges ─────────────────────────────────── */
.confidentiality-badge {
    display: inline-flex;
    align-items: center;
    padding: .18rem .55rem;
    border-radius: var(--radius-sm);
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
}

.conf-normal          { background: #f3f4f6; color: #374151; }
.conf-confidential    { background: #fef3c7; color: #92400e; }
.conf-very-confidential { background: #fee2e2; color: #991b1b; }

/* ── Type Badges (Archive) ──────────────────────────────────── */
.badge-type {
    display: inline-flex;
    align-items: center;
    padding: .2rem .6rem;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
}

.badge-inbound  { background: #e0f2fe; color: #0369a1; }
.badge-outbound { background: #d1fae5; color: #065f46; }
.badge-internal { background: #fef9c3; color: #854d0e; }

/* ── Tables ─────────────────────────────────────────────────── */
.table { font-size: .82rem; }
.table th { font-weight: 600; color: var(--text-muted); font-size: .77rem; text-transform: uppercase; letter-spacing: .02em; padding: .65rem .75rem; }
.table td { padding: .6rem .75rem; vertical-align: middle; }
.table-hover tbody tr:hover { background: #f8faff; }
.table-danger-soft { background: #fff5f5; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn { font-family: 'Cairo', sans-serif; font-weight: 600; border-radius: var(--radius-sm); }
.btn-primary   { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-xs {
    padding: .15rem .4rem;
    font-size: .75rem;
    border-radius: 4px;
    line-height: 1.4;
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-control, .form-select {
    font-family: 'Cairo', sans-serif;
    font-size: .83rem;
    border-color: var(--border-color);
    border-radius: var(--radius-sm);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}

.form-label { font-weight: 600; font-size: .82rem; color: var(--text-main); margin-bottom: .35rem; }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination .page-link {
    font-family: 'Cairo', sans-serif;
    font-size: .8rem;
    color: var(--primary);
    border-color: var(--border-color);
}

.pagination .page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
}

/* ── Unread dot (internal messages) ────────────────────────── */
.unread-dot {
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--primary);
    margin-left: .4rem;
    vertical-align: middle;
}

/* ── Avatar XS ──────────────────────────────────────────────── */
.avatar-xs {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    flex-shrink: 0;
}

/* ── Pipeline Stages (Outbound) ─────────────────────────────── */
.pipeline-stage {
    border-radius: var(--radius-md);
    padding: 1rem;
    text-align: center;
    border: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition);
}

.pipeline-count { font-size: 2rem; font-weight: 800; line-height: 1; }
.pipeline-label { font-size: .8rem; font-weight: 600; margin-top: .3rem; }

.pipeline-draft    { background: #f3f4f6; border-color: #d1d5db; color: #374151; }
.pipeline-review   { background: #fef9c3; border-color: #fcd34d; color: #854d0e; }
.pipeline-approval { background: #fef3c7; border-color: #f59e0b; color: #92400e; }
.pipeline-ready    { background: #d1fae5; border-color: #34d399; color: #065f46; }

.pipeline-stage:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

/* ── Settings Items ─────────────────────────────────────────── */
.settings-item-card {
    background: #f8faff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.settings-nav .nav-link {
    color: var(--text-main);
    border-radius: var(--radius-sm);
    padding: .6rem .9rem;
    font-size: .85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    margin-bottom: 2px;
}

.settings-nav .nav-link:hover { background: var(--primary-soft); color: var(--primary); }
.settings-nav .nav-link.active { background: var(--primary); color: #fff; }

/* ── Upload Area ────────────────────────────────────────────── */
.upload-area {
    background: #f8faff;
    border-style: dashed !important;
    border-color: #c7d7f9 !important;
    transition: var(--transition);
}

.upload-area:hover { background: var(--primary-soft); border-color: var(--primary) !important; }

/* ── Footer ─────────────────────────────────────────────────── */
.page-footer {
    height: var(--footer-height);
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    font-size: .78rem;
    color: var(--text-muted);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 991.98px) {
    .main-wrapper { margin-right: 0 !important; }
}

@media (max-width: 575.98px) {
    .stat-value { font-size: 1.4rem; }
    .page-content { padding-top: calc(var(--topbar-height) + .5rem); }
}
