/* ============================================================
   نظام الحضور والانصراف - Web Edition
   Design: Premium Dark Theme with Arabic support
   ============================================================ */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: tajawal;
}

:root {
    --bg-primary: #080c14;
    --bg-secondary: #0d1526;
    --bg-card: #111827;
    --bg-card-alt: #151e2e;
    --border-color: rgba(99, 179, 237, 0.12);
    --border-glow: rgba(99, 179, 237, 0.35);

    --text-primary: #f0f6ff;
    --text-secondary: #8ba3c7;
    --text-muted: #4a6080;

    --accent-blue: #3b82f6;
    --accent-blue-light: #60a5fa;
    --accent-cyan: #06b6d4;

    --green: #10b981;
    --green-light: #34d399;
    --green-glow: rgba(16, 185, 129, 0.3);

    --red: #ef4444;
    --red-light: #f87171;
    --red-glow: rgba(239, 68, 68, 0.3);

    --yellow: #f59e0b;
    --yellow-glow: rgba(245, 158, 11, 0.3);

    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;
    --radius-full: 9999px;

    --shadow-card: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(99, 179, 237, 0.06);
    --shadow-btn: 0 8px 25px rgba(0, 0, 0, 0.3);
    --transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #f1f5f9;
    --bg-card: #ffffff;
    --bg-card-alt: #f8fafc;
    --border-color: rgba(0, 0, 0, 0.08);
    --border-glow: rgba(59, 130, 246, 0.1);

    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;

    --shadow-card: 0 20px 50px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.02);
    --shadow-btn: 0 4px 15px rgba(59, 130, 246, 0.15);
}

html,
body {
    min-height: 100%;
    font-family: 'Tajawal', 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    overflow-y: auto;
}

/* =========== ANIMATED BACKGROUND =========== */
.bg-particles {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    background:
        radial-gradient(ellipse 80% 50% at 20% 20%, rgba(59, 130, 246, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 80% 80%, rgba(6, 182, 212, 0.06) 0%, transparent 60%),
        radial-gradient(ellipse 50% 60% at 50% 50%, rgba(16, 185, 129, 0.04) 0%, transparent 70%);
    animation: bgShift 12s ease-in-out infinite alternate;
}

@keyframes bgShift {
    0% {
        filter: hue-rotate(0deg);
    }

    100% {
        filter: hue-rotate(20deg);
    }
}

.hidden {
    display: none !important;
}

.particle {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99, 179, 237, 0.6) 0%, transparent 70%);
    animation: floatParticle linear infinite;
    pointer-events: none;
}

.particle:nth-child(1) {
    width: 300px;
    height: 300px;
    top: -150px;
    left: -100px;
    animation-duration: 18s;
    opacity: 0.08;
}

.particle:nth-child(2) {
    width: 200px;
    height: 200px;
    top: 60%;
    right: -80px;
    animation-duration: 22s;
    opacity: 0.06;
    animation-delay: -5s;
}

.particle:nth-child(3) {
    width: 150px;
    height: 150px;
    bottom: -50px;
    left: 30%;
    animation-duration: 16s;
    opacity: 0.05;
    animation-delay: -10s;
}

.particle:nth-child(4) {
    width: 100px;
    height: 100px;
    top: 20%;
    right: 20%;
    animation-duration: 14s;
    opacity: 0.07;
    animation-delay: -2s;
}

.particle:nth-child(5) {
    width: 80px;
    height: 80px;
    top: 70%;
    left: 10%;
    animation-duration: 20s;
    opacity: 0.06;
    animation-delay: -8s;
}

.particle:nth-child(6) {
    width: 60px;
    height: 60px;
    top: 40%;
    left: 60%;
    animation-duration: 25s;
    opacity: 0.05;
    animation-delay: -15s;
}

@keyframes floatParticle {
    0% {
        transform: translateY(0) rotate(0deg) scale(1);
    }

    33% {
        transform: translateY(-30px) rotate(120deg) scale(1.1);
    }

    66% {
        transform: translateY(15px) rotate(240deg) scale(0.9);
    }

    100% {
        transform: translateY(0) rotate(360deg) scale(1);
    }
}

/* =========== APP CONTAINER =========== */
.app-container {
    position: relative;
    z-index: 1;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

@media (max-width: 600px) {
    .app-container {
        align-items: flex-start;
        padding: 20px 10px;
    }
}

/* =========== SCREENS =========== */
.screen {
    display: none;
    width: 100%;
    max-width: 480px;
    /* Default for login/register */
    animation: fadeSlideIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.screen#screen-dashboard,
.screen#screen-profile {
    max-width: 850px;
    /* Wider for dashboard/profile */
}

.screen.active {
    display: flex;
    justify-content: center;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* =========== CARD =========== */
.card {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: relative;
    margin-bottom: 20px;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(99, 179, 237, 0.4), transparent);
}

/* =========== REGISTRATION SCREEN =========== */
.card-header {
    padding: 40px 32px 24px;
    text-align: center;
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.08) 0%, transparent 100%);
}

.logo-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 30px rgba(59, 130, 246, 0.4);
    animation: logoPulse 3s ease-in-out infinite;
}

.logo-icon svg {
    width: 40px;
    height: 40px;
    color: white;
}

@keyframes logoPulse {

    0%,
    100% {
        box-shadow: 0 8px 30px rgba(59, 130, 246, 0.4);
        transform: scale(1);
    }

    50% {
        box-shadow: 0 12px 40px rgba(59, 130, 246, 0.6);
        transform: scale(1.05);
    }
}

.card-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.card-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.card-body {
    padding: 24px 32px 40px;
}

/* =========== FORM =========== */
.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.input-wrapper {
    position: relative;
}

.form-input {
    width: 100%;
    padding: 16px 20px 16px 52px;
    background: var(--bg-secondary);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: 'Tajawal', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    transition: var(--transition);
    outline: none;
    text-align: right;
    direction: rtl;
}

.form-input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.form-input:focus {
    border-color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.06);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.input-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    pointer-events: none;
}

/* =========== BUTTONS =========== */
.btn {
    width: 100%;
    padding: 16px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-family: 'Tajawal', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    color: white;
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.4);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 12px 35px rgba(59, 130, 246, 0.55);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-arrow {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* =========== DASHBOARD CARD =========== */
.dashboard-card {
    padding: 0;
}

.dash-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 28px;
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.07) 0%, transparent 100%);
    border-bottom: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.user-avatar {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 800;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.35);
}

.user-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-bottom: 2px;
}

.user-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.logout-btn-minimal {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    color: var(--text-muted);
}

.logout-btn-minimal:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
    color: var(--red-light);
    transform: scale(1.05);
}

/* =========== STATUS ORB =========== */
.status-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 24px 20px;
    gap: 16px;
}

.status-orb {
    width: 80px;
    height: 80px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.orb-inner {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: var(--transition);
    box-shadow: 0 0 20px rgba(74, 96, 128, 0.5);
    z-index: 2;
}

.orb-ring,
.ring-2 {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--text-muted);
    animation: orbRingExpand 2s ease-out infinite;
    opacity: 0;
    transition: border-color 0.5s ease;
}

.ring-2 {
    animation-delay: 1s;
}

@keyframes orbRingExpand {
    0% {
        transform: scale(0.5);
        opacity: 0.8;
    }

    100% {
        transform: scale(1.6);
        opacity: 0;
    }
}

/* Status States */
.status-orb.connected .orb-inner {
    background: var(--green);
    box-shadow: 0 0 30px var(--green-glow), 0 0 70px rgba(16, 185, 129, 0.15);
}

.status-orb.connected .orb-ring,
.status-orb.connected .ring-2 {
    border-color: var(--green);
}

.status-orb.disconnected .orb-inner {
    background: var(--red);
    box-shadow: 0 0 30px var(--red-glow);
}

.status-orb.disconnected .orb-ring,
.status-orb.disconnected .ring-2 {
    border-color: var(--red);
}

.status-orb.checking .orb-inner {
    background: var(--yellow);
    box-shadow: 0 0 30px var(--yellow-glow);
    animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }
}

.status-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: var(--transition);
}

/* =========== CLOCK =========== */
.clock-section {
    text-align: center;
    padding: 10px 24px 20px;
}

.clock {
    font-size: 2.8rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: 0.08em;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    margin-bottom: 6px;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-blue-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.date {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.04em;
}

/* =========== INFO CARDS =========== */
.info-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 0 20px 20px;
}

.info-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 12px;
    text-align: center;
    transition: var(--transition);
}

.info-card.active {
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.06);
}

.info-card-label {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 6px;
}

.info-card-value {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent-blue-light);
    font-variant-numeric: tabular-nums;
}

/* =========== ACTION BUTTONS =========== */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0 20px 28px;
}

.btn-checkin,
.btn-checkout {
    height: 60px;
    border-radius: var(--radius-md);
    font-size: 1.1rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    font-family: 'Tajawal', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.btn-checkin {
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
    box-shadow: 0 8px 28px rgba(16, 185, 129, 0.4);
}

.btn-checkin:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 14px 40px rgba(16, 185, 129, 0.55);
}

.btn-checkin:active:not(:disabled) {
    transform: translateY(0);
}

.btn-checkout {
    background: linear-gradient(135deg, #b91c1c, #ef4444);
    color: white;
    box-shadow: 0 8px 28px rgba(239, 68, 68, 0.35);
}

.btn-checkout:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 14px 40px rgba(239, 68, 68, 0.5);
}

.btn-checkout:active:not(:disabled) {
    transform: translateY(0);
}

.btn-checkin:disabled,
.btn-checkout:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-icon {
    font-size: 1.3rem;
}

.btn-shimmer {
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.12), transparent);
    animation: shimmer 2.5s ease-in-out infinite;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }

    100% {
        left: 160%;
    }
}

/* =========== LOADING OVERLAY =========== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 12, 20, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: fadeIn 0.2s ease;
}

.loading-overlay.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.loading-spinner {
    text-align: center;
}

.spinner-ring {
    width: 60px;
    height: 60px;
    border: 3px solid rgba(99, 179, 237, 0.1);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 18px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-text {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    font-family: 'Tajawal', sans-serif;
}

/* =========== TOAST NOTIFICATION =========== */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 24px;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
    z-index: 3000;
    max-width: 380px;
    text-align: center;
    animation: toastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    direction: rtl;
}

.toast.hidden {
    display: none;
}

.toast.success {
    border-color: rgba(16, 185, 129, 0.4);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), var(--bg-card));
    color: var(--green-light);
}

.toast.error {
    border-color: rgba(239, 68, 68, 0.4);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), var(--bg-card));
    color: var(--red-light);
}

.toast.info {
    border-color: rgba(59, 130, 246, 0.4);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), var(--bg-card));
    color: var(--accent-blue-light);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* =========== RESPONSIVE =========== */
@media (max-height: 700px) {
    .status-section {
        padding: 16px 24px 10px;
    }

    .status-orb {
        width: 60px;
        height: 60px;
    }

    .orb-inner {
        width: 28px;
        height: 28px;
    }

    .clock {
        font-size: 2.2rem;
    }

    .info-cards {
        padding: 0 16px 12px;
    }

    .action-buttons {
        padding: 0 16px 20px;
    }

    .btn-checkin,
    .btn-checkout {
        height: 52px;
    }
}

@media (max-width: 400px) {
    .app-container {
        padding: 10px;
    }

    .card-body {
        padding: 15px 15px 25px;
    }

    .user-name {
        font-size: 1.1rem;
    }

    .dash-header {
        padding: 15px;
    }
}

/* Fix profile grid for small screens */
@media (max-width: 600px) {
    .form-grid {
        grid-template-columns: 1fr !important;
    }

    .profile-preview-lg {
        margin-bottom: 15px;
    }
}

/* =========== PROFILE STYLES =========== */
.profile-preview-lg {
    text-align: center;
    margin-bottom: 25px;
}

.profile-preview-lg img {
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
    transition: var(--transition);
}

.profile-preview-lg img:hover {
    transform: scale(1.05);
}

.field-divider {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent-blue-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-wrapper input:disabled {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.05);
    opacity: 0.6;
    cursor: not-allowed;
}

/* Detailed Profile Response Classes */
.profile-screen {
    max-width: 650px !important;
}

.profile-header {
    padding: 30px 24px 20px;
}

.profile-preview-img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    display: none;
    margin: 0 auto 10px;
    border: 3px solid var(--blue);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.profile-avatar-placeholder {
    width: 80px;
    height: 80px;
    font-size: 32px;
    margin: 0 auto 10px;
}

.profile-body {
    padding: 24px;
}

.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.full-width {
    grid-column: span 2;
}

.field-divider-row {
    grid-column: span 2;
    margin: 10px 0;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent-blue-light);
    text-transform: uppercase;
}

.profile-actions {
    display: flex;
    gap: 12px;
    margin-top: 25px;
}

.profile-actions .btn-secondary {
    flex: 1;
}

.profile-actions .btn-primary {
    flex: 2;
}

/* Mobil-specific profile adjustments */
@media (max-width: 600px) {
    .profile-grid {
        grid-template-columns: 1fr;
    }

    .full-width {
        grid-column: span 1;
    }

    .field-divider-row {
        grid-column: span 1;
    }

    .profile-actions {
        flex-direction: column-reverse;
    }

    .profile-actions button {
        width: 100%;
        flex: none !important;
    }

    .profile-body {
        padding: 15px;
    }

    .profile-header {
        padding: 20px 15px;
    }
}