/* =============================================
   نظام إدارة المركز التعليمي - الأنماط الرئيسية
   Educational Center CRM - Main Styles
   ============================================= */

/* --- Design Tokens --- */
:root {
    --primary: #00416A;
    --primary-light: #006BAE;
    --primary-lighter: #BCE5FF;
    --primary-rgb: 0, 65, 106;
    --secondary: #36454F;
    --success: #198754;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #0dcaf0;

    --bg-body: #f0f2f5;
    --bg-card: #ffffff;
    --bg-sidebar: #1a1a2e;
    --bg-sidebar-hover: #16213e;
    --bg-sidebar-active: #00416A;

    --text-primary: #1a1a2e;
    --text-secondary: #6c757d;
    --text-light: #ffffff;
    --text-muted: #9ca3af;

    --border-color: #e2e8f0;
    --border-radius: 0.625rem;
    --border-radius-lg: 1rem;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);

    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --header-height: 65px;

    --transition: all 0.3s ease;
    --font-family: 'Cairo', sans-serif;
}

/* --- Global Reset & Base --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-body);
    color: var(--text-primary);
    direction: rtl;
    font-size: 14px;
    line-height: 1.6;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-body);
}
::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    color: var(--text-light);
    z-index: 1040;
    transition: var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    min-height: var(--header-height);
}

.sidebar-brand-icon {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.sidebar-brand-text {
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
}

.sidebar-nav {
    padding: 12px 0;
}

.sidebar-nav-label {
    padding: 12px 20px 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
}

.sidebar-nav-item {
    list-style: none;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.7);
    transition: var(--transition);
    border-radius: 0;
    font-size: 14px;
    cursor: pointer;
    border-right: 3px solid transparent;
}

.sidebar-nav-link:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-light);
}

.sidebar-nav-link.active {
    background: var(--bg-sidebar-active);
    color: var(--text-light);
    border-right-color: var(--primary-light);
}

.sidebar-nav-link i {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

/* --- Header --- */
.main-header {
    position: fixed;
    top: 0;
    right: var(--sidebar-width);
    left: 0;
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    z-index: 1030;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.header-user:hover {
    background: var(--bg-body);
}

.header-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.header-user-info {
    text-align: right;
}

.header-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-user-role {
    font-size: 11px;
    color: var(--text-secondary);
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 6px;
}

/* --- Main Content --- */
.main-content {
    margin-right: var(--sidebar-width);
    margin-top: var(--header-height);
    padding: 24px;
    min-height: calc(100vh - var(--header-height));
    transition: var(--transition);
}

/* --- Page Header --- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.breadcrumb-custom {
    font-size: 13px;
    color: var(--text-secondary);
}

.breadcrumb-custom a {
    color: var(--primary);
}

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

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* --- Stat Cards --- */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

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

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

.stat-card-icon.primary {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
}

.stat-card-icon.success {
    background: rgba(25,135,84,0.1);
    color: var(--success);
}

.stat-card-icon.warning {
    background: rgba(255,193,7,0.15);
    color: #b8860b;
}

.stat-card-icon.danger {
    background: rgba(220,53,69,0.1);
    color: var(--danger);
}

.stat-card-icon.info {
    background: rgba(13,202,240,0.1);
    color: #0aa2c0;
}

.stat-card-info h3 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 2px;
    color: var(--text-primary);
}

.stat-card-info p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

/* --- Tables --- */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table-toolbar {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border-color);
}

.table {
    margin-bottom: 0;
    font-size: 13px;
}

.table thead th {
    background: var(--bg-body);
    border-bottom: 2px solid var(--border-color);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 16px;
    white-space: nowrap;
}

.table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.table tbody tr:hover {
    background: rgba(var(--primary-rgb), 0.03);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* --- Forms --- */
.form-label {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-control,
.form-select {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 10px 14px;
    font-size: 14px;
    transition: var(--transition);
    font-family: var(--font-family);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

.form-text {
    font-size: 12px;
    color: var(--text-muted);
}

/* --- Buttons --- */
.btn {
    font-family: var(--font-family);
    font-weight: 600;
    border-radius: var(--border-radius);
    padding: 8px 18px;
    font-size: 14px;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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

.btn-primary:hover {
    background: var(--primary-light);
    border-color: var(--primary-light);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

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

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius);
}

/* --- Badges --- */
.badge-stage {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-primary { background: rgba(var(--primary-rgb), 0.1); color: var(--primary); }
.badge-success-soft { background: rgba(25,135,84,0.1); color: var(--success); }
.badge-warning-soft { background: rgba(255,193,7,0.15); color: #b8860b; }
.badge-danger-soft { background: rgba(220,53,69,0.1); color: var(--danger); }
.badge-info-soft { background: rgba(13,202,240,0.1); color: #0aa2c0; }

/* --- Attendance Page --- */
.attendance-scanner {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: var(--border-radius-lg);
    padding: 40px;
    text-align: center;
    color: white;
    box-shadow: var(--shadow-lg);
}

.scanner-icon {
    width: 100px;
    height: 100px;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 48px;
    animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
    0% { box-shadow: 0 0 0 0 rgba(255,255,255,0.3); }
    70% { box-shadow: 0 0 0 20px rgba(255,255,255,0); }
    100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); }
}

.scanner-input {
    max-width: 400px;
    margin: 0 auto;
}

.scanner-input .form-control {
    background: rgba(255,255,255,0.15);
    border: 2px solid rgba(255,255,255,0.3);
    color: white;
    font-size: 18px;
    text-align: center;
    padding: 14px;
    border-radius: var(--border-radius);
}

.scanner-input .form-control::placeholder {
    color: rgba(255,255,255,0.6);
}

.scanner-input .form-control:focus {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.6);
    box-shadow: 0 0 0 3px rgba(255,255,255,0.15);
}

.attendance-notification {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    min-width: 350px;
    animation: slideDown 0.4s ease;
}

@keyframes slideDown {
    from { transform: translateX(-50%) translateY(-30px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

.attendance-record {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--border-radius);
    margin-bottom: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.attendance-record:hover {
    box-shadow: var(--shadow-sm);
}

.attendance-record .record-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.attendance-record .record-icon.check-in {
    background: rgba(25,135,84,0.1);
    color: var(--success);
}

.attendance-record .record-icon.check-out {
    background: rgba(220,53,69,0.1);
    color: var(--danger);
}

/* --- Login Page --- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-sidebar) 0%, var(--primary) 100%);
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    padding: 40px;
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo-icon {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 32px;
    color: white;
}

.login-logo h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.login-logo p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* --- Search Page --- */
.search-hero {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: var(--border-radius-lg);
    padding: 40px;
    text-align: center;
    color: white;
    margin-bottom: 24px;
}

.search-hero h3 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 16px;
}

.search-input-wrapper {
    max-width: 600px;
    margin: 0 auto;
    position: relative;
}

.search-input-wrapper .form-control {
    padding: 14px 20px 14px 50px;
    border-radius: 50px;
    border: none;
    font-size: 16px;
}

.search-input-wrapper i {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 18px;
}

/* --- Settings --- */
.settings-nav .nav-link {
    color: var(--text-secondary);
    padding: 10px 20px;
    border-radius: var(--border-radius);
    font-weight: 600;
    font-size: 14px;
}

.settings-nav .nav-link.active {
    background: var(--primary);
    color: white;
}

/* --- Responsive --- */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-header {
        right: 0;
    }
    .main-content {
        margin-right: 0;
    }
    .sidebar-toggle {
        display: block;
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 1035;
    }
    .sidebar-overlay.show {
        display: block;
    }
}

@media (max-width: 575px) {
    .main-content {
        padding: 16px;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .stat-card {
        padding: 16px;
    }
    .stat-card-icon {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
    .stat-card-info h3 {
        font-size: 20px;
    }
    .table-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
}

/* --- Utility --- */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gap-grid { gap: 20px; }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 60px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h5 {
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* --- Activity Timeline --- */
.activity-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.activity-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}

.activity-content {
    flex: 1;
}

.activity-content .time {
    font-size: 12px;
    color: var(--text-muted);
}

/* --- Toast Notification --- */
.toast-container {
    position: fixed;
    top: 80px;
    left: 20px;
    z-index: 9999;
}

/* --- Print --- */
@media print {
    .sidebar, .main-header, .btn, .table-toolbar { display: none !important; }
    .main-content { margin: 0; padding: 0; }
}
