/* دفتر امتیاز مرکز — app.css */
@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --primary: #1E3A8A;
    --primary-light: #DBEAFE;
    --success: #16A34A;
    --danger: #DC2626;
    --warning: #F59E0B;
    --text: #334155;
    --text-muted: #64748B;
    --bg: #F8FAFC;
    --card: #FFFFFF;
    --border: #E2E8F0;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
    --shadow-lg: 0 8px 30px rgba(30,58,138,.12);
    --sidebar-w: 260px;
    --transition: .25s cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes countUp { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: scale(1); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

.animate-in { animation: fadeIn .4s ease both; }
.animate-stagger > * { animation: fadeIn .4s ease both; }
.animate-stagger > *:nth-child(1) { animation-delay: .05s; }
.animate-stagger > *:nth-child(2) { animation-delay: .1s; }
.animate-stagger > *:nth-child(3) { animation-delay: .15s; }
.animate-stagger > *:nth-child(4) { animation-delay: .2s; }
.animate-stagger > *:nth-child(5) { animation-delay: .25s; }
.animate-stagger > *:nth-child(6) { animation-delay: .3s; }

/* Guest / Login */
.guest-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; position: relative; overflow: hidden; }
.guest-bg {
    position: fixed; inset: 0;
    background: linear-gradient(135deg, #1E3A8A 0%, #3B82F6 50%, #DBEAFE 100%);
    z-index: 0;
}
.guest-bg::after {
    content: ''; position: absolute; inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.guest-container { position: relative; z-index: 1; width: 100%; max-width: 420px; padding: 1rem; }

.login-card, .install-card {
    background: var(--card);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}
.login-header { text-align: center; margin-bottom: 1.5rem; }
.login-logo {
    width: 56px; height: 56px; margin: 0 auto .75rem;
    background: linear-gradient(135deg, var(--primary), #3B82F6);
    color: #fff; border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
    animation: pulse 2s ease infinite;
}
.login-header h1 { font-size: 1.25rem; color: var(--primary); }
.login-header p { color: var(--text-muted); font-size: .875rem; }

/* App Layout */
.app-wrapper { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w);
    background: var(--primary);
    color: #fff;
    display: flex; flex-direction: column;
    position: fixed; top: 0; right: 0; bottom: 0;
    z-index: 100;
    transition: transform var(--transition);
}
.sidebar-brand {
    display: flex; align-items: center; gap: .75rem;
    padding: 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.brand-icon {
    width: 40px; height: 40px; background: rgba(255,255,255,.15);
    border-radius: 10px; display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
}
.brand-title { font-weight: 700; font-size: .95rem; }
.brand-sub { font-size: .7rem; opacity: .7; }
.sidebar-nav { flex: 1; padding: .75rem; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: .6rem;
    padding: .7rem 1rem; border-radius: 10px;
    color: rgba(255,255,255,.8); text-decoration: none;
    margin-bottom: .25rem; transition: all var(--transition);
    font-size: .9rem;
}
.nav-item:hover, .nav-item.active {
    background: rgba(255,255,255,.15); color: #fff;
}
.nav-item.active { font-weight: 700; }
.sidebar-logout { padding: 1rem; border-top: 1px solid rgba(255,255,255,.1); }

.app-main { flex: 1; margin-right: var(--sidebar-w); min-width: 0; }
.app-header {
    display: flex; align-items: center; gap: 1rem;
    padding: 1rem 1.5rem;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
}
.menu-toggle {
    display: none; flex-direction: column; gap: 5px;
    background: none; border: none; cursor: pointer; padding: 4px;
}
.menu-toggle span { display: block; width: 22px; height: 2px; background: var(--text); border-radius: 2px; transition: var(--transition); }
.page-title { font-size: 1.1rem; font-weight: 700; flex: 1; }
.header-user { text-align: left; }
.user-name { display: block; font-weight: 700; font-size: .875rem; }
.user-role { font-size: .75rem; color: var(--text-muted); }
.app-content { padding: 1.5rem; }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 99; }

/* Cards & Stats */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}
.card-header h2 { font-size: 1rem; font-weight: 700; }
.card-body { padding: 1.25rem; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}
.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--primary); animation: countUp .5s ease; }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }
.stat-sub { font-size: .7rem; color: var(--text-muted); }
.stat-card.accent-green .stat-value { color: var(--success); }
.stat-card.accent-orange .stat-value { color: var(--warning); }
.stat-card.accent-red .stat-value { color: var(--danger); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.mt-2 { margin-top: .5rem; } .mt-3 { margin-top: 1rem; } .mt-4 { margin-top: 1.5rem; }
.mb-3 { margin-bottom: 1rem; }
.flex-1 { flex: 1; } .flex-2 { flex: 2; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .35rem; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: .6rem .85rem;
    border: 1.5px solid var(--border); border-radius: 8px;
    font-family: inherit; font-size: .9rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    background: #fff;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 140px; }
.form-actions { display: flex; gap: .5rem; margin-top: 1rem; }
.checkbox-label { display: flex; align-items: center; gap: .5rem; font-size: .875rem; cursor: pointer; }
.form-select-sm { padding: .5rem; border-radius: 8px; border: 1px solid var(--border); }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .55rem 1.1rem; border: none; border-radius: 8px;
    font-family: inherit; font-size: .875rem; font-weight: 600;
    cursor: pointer; text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #1e40af; transform: translateY(-1px); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; }

/* Tables */
.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th {
    text-align: right; padding: .75rem 1rem;
    background: var(--bg); font-weight: 600;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.data-table td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); }
.data-table tr:hover td { background: #f1f5f9; }
.actions { display: flex; gap: .25rem; flex-wrap: wrap; }
.inline-form { display: inline; }

/* Status badges */
.status {
    display: inline-block; padding: .2rem .6rem;
    border-radius: 20px; font-size: .75rem; font-weight: 600;
}
.status-active, .status-approved { background: #DCFCE7; color: #166534; }
.status-inactive, .status-rejected { background: #FEE2E2; color: #991B1B; }
.status-pending { background: #FEF3C7; color: #92400E; }
.status-reversed { background: #E0E7FF; color: #3730A3; }
.badge-points { background: var(--primary-light); color: var(--primary); padding: .2rem .6rem; border-radius: 20px; font-weight: 700; }

.text-green { color: var(--success); font-weight: 600; }
.text-red { color: var(--danger); font-weight: 600; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }

/* Alerts */
.alert {
    padding: .85rem 1rem; border-radius: 8px; margin-bottom: 1rem;
    font-size: .875rem; font-weight: 500;
}
.alert-success { background: #DCFCE7; color: #166534; border: 1px solid #BBF7D0; }
.alert-error { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }

/* Toolbar */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.search-form { display: flex; gap: .5rem; flex: 1; flex-wrap: wrap; }
.search-input {
    flex: 1; min-width: 180px; padding: .55rem 1rem;
    border: 1.5px solid var(--border); border-radius: 8px;
    font-family: inherit;
}
.search-bar { margin-bottom: .5rem; }

/* Rank list */
.rank-list { list-style: none; }
.rank-item {
    display: flex; align-items: center; gap: .75rem;
    padding: .6rem 0; border-bottom: 1px solid var(--border);
}
.rank-num {
    width: 28px; height: 28px; background: var(--primary-light);
    color: var(--primary); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .8rem; font-weight: 700;
}
.rank-name { flex: 1; }
.rank-score { font-weight: 700; color: var(--primary); }

/* Activity list */
.activity-list { list-style: none; }
.activity-item {
    display: flex; align-items: flex-start; gap: .75rem;
    padding: .85rem 0; border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}
.activity-item:hover { background: #f8fafc; margin: 0 -1rem; padding-left: 1rem; padding-right: 1rem; }
.activity-points {
    font-weight: 700; font-size: 1rem; min-width: 60px;
    padding: .25rem .5rem; border-radius: 8px; text-align: center;
}
.activity-item.positive .activity-points { background: #DCFCE7; color: var(--success); }
.activity-item.negative .activity-points { background: #FEE2E2; color: var(--danger); }
.activity-title { font-weight: 600; font-size: .875rem; }
.activity-meta { font-size: .75rem; color: var(--text-muted); margin-top: .15rem; }
.activity-info { flex: 1; }

/* Children grid */
.children-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
}
.child-card {
    background: var(--card); border-radius: var(--radius);
    padding: 1.25rem; text-align: center;
    box-shadow: var(--shadow); text-decoration: none; color: inherit;
    transition: all var(--transition);
    border: 2px solid transparent;
}
.child-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}
.child-card-name { font-weight: 700; margin-bottom: .5rem; }
.child-card-points {
    font-size: 1.5rem; font-weight: 700; color: var(--primary);
    transition: transform .3s ease;
}
.child-card:hover .child-card-points { transform: scale(1.1); }
.child-card-group { font-size: .75rem; color: var(--text-muted); margin-top: .25rem; }

.big-points { font-size: 2.5rem; font-weight: 700; color: var(--primary); }
.big-points-wrap { text-align: center; }
.child-profile-header {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--card); padding: 1.5rem; border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* Progress */
.progress-row { display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem; font-size: .875rem; }
.progress-bar { flex: 1; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-bar.large { height: 12px; }
.progress-fill {
    height: 100%; background: linear-gradient(90deg, var(--primary), #3B82F6);
    border-radius: 4px; transition: width 1s ease;
}
.progress-card { background: var(--card); padding: 1.25rem; border-radius: var(--radius); box-shadow: var(--shadow); }
.progress-label { font-size: .875rem; font-weight: 600; margin-bottom: .5rem; }

.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.quick-btn {
    display: block; padding: 1rem; text-align: center;
    background: var(--bg); border-radius: 10px;
    text-decoration: none; color: var(--primary); font-weight: 600;
    transition: all var(--transition);
}
.quick-btn:hover { background: var(--primary-light); transform: translateY(-2px); }

.info-box {
    background: var(--primary-light); color: var(--primary);
    padding: .75rem 1rem; border-radius: 8px; font-size: .875rem;
}
.points-input-lg { font-size: 1.25rem !important; font-weight: 700; text-align: center; }

/* Child dashboard */
.child-dashboard { max-width: 520px; margin: 0 auto; }
.child-greeting { text-align: center; margin-bottom: 1.5rem; }
.child-greeting h2 { font-size: 1.3rem; color: var(--primary); }
.motivation-text {
    background: linear-gradient(135deg, #FEF3C7, #FDE68A);
    padding: .75rem 1rem; border-radius: 12px;
    margin-top: .75rem; font-size: .9rem; font-weight: 600;
    animation: fadeIn .6s ease .3s both;
}
.child-score-card {
    position: relative; text-align: center;
    background: linear-gradient(135deg, var(--primary), #3B82F6);
    color: #fff; border-radius: 24px;
    padding: 2rem; margin-bottom: 1rem;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.score-label { font-size: .9rem; opacity: .85; }
.score-value {
    font-size: 3.5rem; font-weight: 700; line-height: 1.1;
    position: relative; z-index: 2;
    transition: transform .5s cubic-bezier(.34,1.56,.64,1);
}
.score-ring {
    position: absolute; inset: 0; opacity: .15;
    display: flex; align-items: center; justify-content: center;
}
.score-ring svg { width: 200px; height: 200px; }
.ring-bg { fill: none; stroke: #fff; stroke-width: 4; }
.ring-fill { fill: none; stroke: #fff; stroke-width: 4; stroke-linecap: round; stroke-dasharray: 283; stroke-dashoffset: 283; transition: stroke-dashoffset 1.5s ease; }

.child-stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.period-tabs { display: flex; gap: .5rem; flex-wrap: wrap; }
.print-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin: 1rem 0; }
.print-report h1 { color: var(--primary); margin-bottom: .5rem; }
@media (max-width: 768px) {
    .child-stats-row { grid-template-columns: 1fr; }
}
.child-stat {
    background: var(--card); border-radius: var(--radius);
    padding: 1rem; text-align: center; box-shadow: var(--shadow);
}
.child-stat-val { display: block; font-size: 1.25rem; font-weight: 700; }
.child-stat-lbl { font-size: .75rem; color: var(--text-muted); }
.child-stat.green .child-stat-val { color: var(--success); }
.child-stat.red .child-stat-val { color: var(--danger); }

.child-activity-list { list-style: none; }
.child-activity-item {
    display: flex; align-items: center; gap: .75rem;
    padding: .85rem 0; border-bottom: 1px solid var(--border);
}
.ca-icon {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1rem;
}
.ca-icon.pos { background: #DCFCE7; color: var(--success); }
.ca-icon.neg { background: #FEE2E2; color: var(--danger); }
.ca-body { flex: 1; }
.ca-title { font-weight: 700; font-size: .875rem; }
.ca-reason { font-size: .8rem; color: var(--text-muted); }
.ca-meta { font-size: .7rem; color: var(--text-muted); }
.ca-points { font-weight: 700; font-size: 1rem; }
.ca-points.pos { color: var(--success); }
.ca-points.neg { color: var(--danger); }

/* Modal */
.modal {
    position: fixed; inset: 0; background: rgba(0,0,0,.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 200; padding: 1rem;
    animation: fadeIn .2s ease;
}
.modal.hidden { display: none; }
.modal-content {
    background: var(--card); border-radius: var(--radius);
    padding: 1.5rem; width: 100%; max-width: 420px;
    box-shadow: var(--shadow-lg);
    animation: slideInRight .3s ease;
}
.modal-content h3 { margin-bottom: 1rem; }

/* Toast */
#toast-container {
    position: fixed; top: 1rem; left: 50%; transform: translateX(-50%);
    z-index: 9999; display: flex; flex-direction: column; gap: .5rem;
    pointer-events: none;
}
.toast {
    padding: .85rem 1.25rem; border-radius: 10px;
    font-size: .875rem; font-weight: 600;
    box-shadow: var(--shadow-lg);
    animation: toastIn .3s ease;
    pointer-events: auto;
    min-width: 280px; text-align: center;
}
.toast-success { background: #166534; color: #fff; }
.toast-error { background: #991B1B; color: #fff; }

/* Logs */
.log-list { list-style: none; font-size: .8rem; }
.log-list li { padding: .4rem 0; border-bottom: 1px solid var(--border); }
.log-time { color: var(--text-muted); margin-left: .5rem; }
.log-action { font-weight: 600; color: var(--primary); }
.backup-list { list-style: none; font-size: .875rem; }
.backup-list a { color: var(--primary); }

.mentor-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.empty-state { text-align: center; padding: 3rem; }
.empty-state h2 { font-size: 3rem; color: var(--primary); }

/* Loading spinner on buttons */
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after {
    content: ''; position: absolute;
    width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: #fff; border-radius: 50%;
    animation: spin .6s linear infinite;
}

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

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(100%); }
    .sidebar.open { transform: none; }
    .sidebar-overlay.open { display: block; }
    .app-main { margin-right: 0; }
    .menu-toggle { display: flex; }
    .grid-2 { grid-template-columns: 1fr; }
    .mentor-summary { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .child-profile-header { flex-direction: column; gap: 1rem; text-align: center; }
    .form-row { flex-direction: column; }
    .score-value { font-size: 2.5rem; }
}

@media (max-width: 480px) {
    .app-content { padding: 1rem; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .children-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Child role: simpler sidebar */
body[data-role="child"] .sidebar { background: linear-gradient(180deg, #1E3A8A, #2563EB); }
