/* Native Arabic & System Font Stack - No External Fonts Required */
:root {
    --app-primary: #1d4ed8;
    --app-primary-dark: #1e40af;
    --app-accent: #3b82f6;
    --app-success: #10b981;
    --app-danger: #ef4444;
    --app-warning: #f59e0b;
    --app-bg: #f8fafc;
    --app-card: #ffffff;
    --app-text: #0f172a;
    --app-muted: #64748b;
    --app-border: #e2e8f0;
    --radius-lg: 20px;
    --radius-md: 14px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Arabic", "Cairo", Tahoma, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--app-bg);
    color: var(--app-text);
    direction: rtl;
    text-align: right;
    min-height: 100vh;
    padding-bottom: 85px; /* for bottom nav */
    user-select: none;
}

/* App Container */
.app-container {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: #ffffff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--app-border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.student-badge {
    display: flex;
    align-items: center;
    gap: 12px;
}

.student-avatar {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}

.student-meta h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--app-text);
}

.student-meta p {
    font-size: 12px;
    color: var(--app-muted);
}

/* Main View Views */
.app-view {
    display: none;
    padding: 20px;
    flex: 1;
}

.app-view.active {
    display: block;
    animation: appFadeIn 0.25s ease-out;
}

@keyframes appFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Big Scan Card */
.scan-hero-card {
    background: linear-gradient(135deg, #1e3a8a, #2563eb);
    color: white;
    border-radius: var(--radius-lg);
    padding: 28px 20px;
    text-align: center;
    margin-bottom: 24px;
    box-shadow: 0 10px 25px -5px rgba(37, 99, 235, 0.4);
    position: relative;
    overflow: hidden;
}

.scan-pulse-btn {
    width: 90px;
    height: 90px;
    background: white;
    color: var(--app-primary);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    margin: 16px 0;
    cursor: pointer;
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7);
    animation: pulse 1.8s infinite;
    border: none;
    outline: none;
}

@keyframes pulse {
    0% { transform: scale(0.96); box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7); }
    70% { transform: scale(1.04); box-shadow: 0 0 0 18px rgba(255, 255, 255, 0); }
    100% { transform: scale(0.96); box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

/* Stats Cards */
.student-stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 24px;
}

.student-stat-box {
    background: var(--app-card);
    border: 1px solid var(--app-border);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
}

.student-stat-box .number {
    font-size: 26px;
    font-weight: 800;
    color: var(--app-primary);
    margin-top: 4px;
}

.student-stat-box .label {
    font-size: 12px;
    color: var(--app-muted);
}

/* History List */
.history-item {
    background: var(--app-card);
    border: 1px solid var(--app-border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item h4 {
    font-size: 15px;
    font-weight: 700;
}

.history-item p {
    font-size: 12px;
    color: var(--app-muted);
    margin-top: 4px;
}

/* Scanner View */
.scanner-container {
    background: #000;
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    min-height: 350px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#qr-reader {
    width: 100% !important;
    border: none !important;
}

#qr-reader__scan_region video {
    border-radius: var(--radius-lg) !important;
    object-fit: cover;
}

.scanner-overlay-box {
    position: absolute;
    width: 220px;
    height: 220px;
    border: 2px dashed #3b82f6;
    border-radius: 16px;
    pointer-events: none;
    box-shadow: 0 0 0 1000px rgba(0, 0, 0, 0.45);
}

/* Bottom Navigation Bar */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 68px;
    background: #ffffff;
    border-top: 1px solid var(--app-border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    max-width: 480px;
    margin: 0 auto;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--app-muted);
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    flex: 1;
    height: 100%;
    transition: color 0.2s;
}

.nav-item.active {
    color: var(--app-primary);
}

.nav-item .icon {
    font-size: 20px;
    margin-bottom: 2px;
}

/* Alerts and Modals */
.feedback-banner {
    padding: 16px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    display: none;
}

.feedback-banner.success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    display: block;
}

.feedback-banner.error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    display: block;
}

/* Modals in App */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
    backdrop-filter: blur(4px);
}

.modal-overlay.active {
    display: flex;
    animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-dialog {
    background: #ffffff;
    width: 100%;
    max-width: 440px;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--app-border);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--app-text);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: var(--app-muted);
}

.form-group {
    margin-bottom: 14px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 700;
    color: var(--app-text);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--app-border);
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    color: var(--app-text);
    background: #fff;
    box-sizing: border-box;
    font-family: inherit;
}

.form-control:focus {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-primary { background: var(--app-primary); color: white; }
.btn-primary:hover { background: var(--app-primary-dark); }
.btn-secondary { background: #f1f5f9; color: #475569; border: 1px solid var(--app-border); }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger { background: var(--app-danger); color: white; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* Install PWA Prompt */
.pwa-install-bar {
    background: #1e293b;
    color: white;
    padding: 12px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pwa-install-bar button {
    background: var(--app-accent);
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
}
