/* =====================================================================
   نظام إدارة الأضاحي - الستايل الرئيسي
   ===================================================================== */

:root {
    --primary: #1a8754;
    --primary-dark: #0d5f3a;
    --primary-light: #d1e7dd;
    --secondary: #d4a017;
    --secondary-light: #fff3cd;
    --danger: #dc3545;
    --info: #0dcaf0;
    --bg: #f5f7f6;
    --card-bg: #ffffff;
    --text: #2c3e50;
    --text-muted: #6c757d;
    --border: #e5e7eb;
    --shadow: 0 2px 8px rgba(0,0,0,.06);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.08);
    --sidebar-w: 260px;
}

* {
    box-sizing: border-box;
}

html, body {
    font-family: 'Tajawal', 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    direction: rtl;
}

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

/* =================== Login Page ============================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    position: relative;
    overflow: hidden;
}
.login-bg-pattern {
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 25% 25%, rgba(255,255,255,.08) 2px, transparent 2px),
        radial-gradient(circle at 75% 75%, rgba(255,255,255,.08) 2px, transparent 2px);
    background-size: 60px 60px;
    pointer-events: none;
}
.login-container {
    width: 100%;
    max-width: 460px;
    padding: 20px;
    position: relative;
    z-index: 1;
}
.login-card {
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0,0,0,.25);
}
.login-header {
    padding: 35px 30px 20px;
    text-align: center;
    background: linear-gradient(180deg, #fff 0%, #f8faf9 100%);
}
.login-logo {
    width: 90px;
    height: 90px;
    margin: 0 auto 15px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-logo img { max-width: 100%; max-height: 100%; }
.logo-placeholder {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
}
.login-header h1 {
    font-size: 1.3rem;
    color: var(--primary);
    margin: 10px 0 5px;
    font-weight: 700;
}
.login-subtitle {
    font-size: .9rem;
    color: var(--text-muted);
    margin: 0;
}
.login-form { padding: 30px; }
.login-form .form-label { font-weight: 600; color: var(--text); }
.login-form .input-group-text { background: var(--primary-light); color: var(--primary); border: none; }
.login-btn {
    background: var(--primary);
    border-color: var(--primary);
    font-weight: 700;
    padding: 12px;
    border-radius: 10px;
    transition: all .2s;
}
.login-btn:hover { background: var(--primary-dark); border-color: var(--primary-dark); transform: translateY(-1px); }
.login-footer { padding: 0 30px 25px; }

/* =================== App Shell ============================ */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    padding: 0;
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: -2px 0 15px rgba(0,0,0,.08);
    transition: transform .3s ease;
}
.sidebar-brand {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,.1);
    display: flex;
    align-items: center;
    gap: 12px;
}
.sidebar-brand img {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: #fff;
    padding: 4px;
}
.brand-text .brand-title { font-weight: 700; font-size: 1.05rem; line-height: 1.1; }
.brand-text .brand-sub { font-size: .8rem; opacity: .85; }

.sidebar-nav { padding: 12px; }
.nav-section {
    color: rgba(255,255,255,.55);
    font-size: .75rem;
    font-weight: 700;
    padding: 16px 12px 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.sidebar-nav .nav-link {
    color: #fff;
    padding: 11px 14px;
    margin-bottom: 4px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all .2s;
    font-weight: 500;
}
.sidebar-nav .nav-link i { font-size: 1.15rem; min-width: 22px; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.12); color: #fff; }
.sidebar-nav .nav-link.active {
    background: var(--secondary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(212,160,23,.4);
}
.sidebar-footer {
    padding: 12px 20px;
    text-align: center;
    opacity: .65;
    font-size: .8rem;
    border-top: 1px solid rgba(255,255,255,.1);
    margin-top: 20px;
}
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 999;
}
.sidebar-backdrop.show { display: block; }

.app-main {
    margin-right: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-header {
    background: #fff;
    padding: 14px 22px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.sidebar-toggle { font-size: 1.5rem; color: var(--primary); }
.header-title { flex: 1; min-width: 0; }
.page-title {
    font-size: 1.2rem;
    margin: 0;
    color: var(--text);
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.committee-name { font-size: .85rem; color: var(--text-muted); }
.header-user { display: flex; align-items: center; gap: 12px; }
.user-info { text-align: end; }
.user-info .user-name { font-weight: 600; color: var(--text); font-size: .92rem; }
.user-info .user-role { font-size: .78rem; color: var(--text-muted); }

.app-content { padding: 24px; flex: 1; }
.app-footer {
    background: #fff;
    padding: 16px 24px;
    text-align: center;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
}

/* =================== Cards ============================ */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: var(--shadow);
    background: var(--card-bg);
    margin-bottom: 20px;
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
    font-weight: 700;
    color: var(--text);
}

/* =================== Stat Cards ============================ */
.stat-card {
    background: linear-gradient(135deg, #fff 0%, #f8fbfa 100%);
    border-radius: 14px;
    padding: 22px;
    box-shadow: var(--shadow);
    border-right: 4px solid var(--primary);
    transition: transform .2s, box-shadow .2s;
    height: 100%;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card.stat-green { border-right-color: var(--primary); }
.stat-card.stat-gold  { border-right-color: var(--secondary); }
.stat-card.stat-blue  { border-right-color: #0d6efd; }
.stat-card.stat-purple { border-right-color: #6f42c1; }
.stat-card.stat-pink   { border-right-color: #d63384; }
.stat-card .stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 12px;
}
.stat-card.stat-gold .stat-icon { background: var(--secondary-light); color: var(--secondary); }
.stat-card .stat-label { color: var(--text-muted); font-size: .9rem; margin-bottom: 4px; }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--text); line-height: 1; }
.stat-card .stat-sub { font-size: .82rem; color: var(--text-muted); margin-top: 6px; }

/* =================== Day Selector Buttons ============================ */
.day-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin: 20px 0;
}
.day-btn {
    padding: 22px 18px;
    border: 2px solid var(--border);
    background: #fff;
    border-radius: 14px;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
}
.day-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.day-btn .day-number {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 6px;
}
.day-btn.day-2 { border-color: #28a745; }
.day-btn.day-2.active { background: #28a745; color: #fff; }
.day-btn.day-3 { border-color: #0d6efd; }
.day-btn.day-3.active { background: #0d6efd; color: #fff; }
.day-btn.day-4 { border-color: #ffc107; }
.day-btn.day-4.active { background: #ffc107; color: #fff; }
.day-btn.day-5 { border-color: #6f42c1; }
.day-btn.day-5.active { background: #6f42c1; color: #fff; }

/* =================== Family Card ============================ */
.family-card {
    background: linear-gradient(135deg, #fff, #f8fbfa);
    border-radius: 14px;
    padding: 22px;
    box-shadow: var(--shadow);
    border: 2px solid var(--primary-light);
    margin: 16px 0;
}
.family-card .family-name {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 12px;
}
.family-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 12px;
}
.family-meta .meta-item { background: rgba(26,135,84,.05); padding: 10px 14px; border-radius: 8px; }
.family-meta .meta-label { font-size: .78rem; color: var(--text-muted); }
.family-meta .meta-value { font-weight: 600; color: var(--text); margin-top: 2px; }

/* =================== Search Bar ============================ */
.search-bar {
    background: #fff;
    border-radius: 14px;
    padding: 6px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 8px;
}
.search-bar input {
    border: none;
    outline: none;
    flex: 1;
    padding: 14px 18px;
    font-size: 1.05rem;
    background: transparent;
}
.search-bar .search-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}
.search-results {
    background: #fff;
    border-radius: 14px;
    margin-top: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    max-height: 400px;
    overflow-y: auto;
}
.search-result-item {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background .15s;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--primary-light); }
.search-result-item .item-info .item-name { font-weight: 600; color: var(--text); }
.search-result-item .item-info .item-meta { font-size: .85rem; color: var(--text-muted); }
.search-result-item .item-badges { display: flex; gap: 4px; }
.stage-badge {
    width: 24px; height: 24px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: .75rem; font-weight: 700;
}
.stage-badge.done { background: #d1e7dd; color: #198754; }
.stage-badge.pending { background: #f8d7da; color: #842029; }

/* =================== Buttons ============================ */
.btn { font-weight: 600; border-radius: 8px; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success { background: var(--primary); border-color: var(--primary); }
.btn-success:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-warning { background: var(--secondary); border-color: var(--secondary); color: #fff; }
.btn-warning:hover { background: #b88a14; border-color: #b88a14; color: #fff; }
.btn-lg-action { padding: 14px 28px; font-size: 1.1rem; font-weight: 700; }

/* =================== Signature Pad ============================ */
.signature-container {
    border: 2px dashed var(--border);
    border-radius: 12px;
    background: #fff;
    padding: 8px;
    margin: 12px 0;
}
.signature-pad-canvas {
    width: 100%;
    height: 200px;
    background: #fafafa;
    border-radius: 8px;
    touch-action: none;
}
.signature-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    padding: 0 8px;
}

/* =================== DataTables ============================ */
table.dataTable {
    width: 100% !important;
    border-collapse: separate;
    border-spacing: 0;
}
table.dataTable thead th {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    border: none !important;
    padding: 12px 10px !important;
}
table.dataTable tbody td { padding: 11px 10px !important; }
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border-radius: 8px;
    border: 1px solid var(--border);
    padding: 6px 10px;
}

/* =================== Voucher Print ============================ */
.voucher-print {
    background: #fff;
    padding: 24px;
    border: 2px dashed var(--primary);
    border-radius: 12px;
    margin: 14px 0;
    text-align: center;
}
.voucher-print .voucher-no { font-size: 1.8rem; font-weight: 700; color: var(--primary); margin: 12px 0; }

@media print {
    body { background: #fff !important; }
    .app-sidebar, .app-header, .app-footer, .sidebar-toggle, .no-print { display: none !important; }
    .app-main { margin: 0 !important; }
    .app-content { padding: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ccc !important; }
}

/* =================== Responsive ============================ */
@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(100%);
    }
    .app-sidebar.show {
        transform: translateX(0);
    }
    .app-main { margin-right: 0; }
}

@media (max-width: 575.98px) {
    .app-content { padding: 14px; }
    .header-title .page-title { font-size: 1rem; }
    .stat-card .stat-value { font-size: 1.6rem; }
    .day-btn { padding: 16px 12px; }
    .day-btn .day-number { font-size: 1.5rem; }
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-state i { font-size: 3rem; opacity: .4; display: block; margin-bottom: 12px; }

/* Loading Spinner */
.spinner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.spinner-overlay.show { display: flex; }
