:root {
    --bg-dark: #030305;
    --primary: #5b21b6; /* Deep Purple */
    --accent: #a855f7;  /* Bright Purple */
    --cyan: #06b6d4;    /* Cyan for contrast */
    --glass: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-main: #ffffff;
    --text-muted: #94a3b8;
    --font-tajawal: 'Tajawal', sans-serif;
}

* {
    box-sizing: border-box;
    scroll-behavior: smooth;
    margin: 0;
    padding: 0;
    font-family: var(--font-tajawal);
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-tajawal);
    margin: 0;
    overflow-x: hidden;
}

/* --- ANIMATED BACKGROUND --- */
.bg-grid {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    z-index: -2;
    mask-image: linear-gradient(to bottom, black 40%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 40%, transparent 100%);
}

.bg-glow {
    position: fixed;
    top: -20%; left: 20%;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.15) 0%, transparent 70%);
    z-index: -1;
    animation: pulseGlow 10s infinite alternate;
}

@keyframes pulseGlow {
    0% { transform: translate(0, 0); opacity: 0.5; }
    100% { transform: translate(-50px, 50px); opacity: 0.8; }
}

/* --- NAVBAR --- */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 8%;
    position: sticky;
    top: 0;
    z-index: 100;
}
.logo { font-size: 22px; font-weight: 900; letter-spacing: -1px; }
.dot { color: var(--cyan); }
.nav-item { text-decoration: none; color: var(--text-muted); margin-left: 25px; font-weight: 700; transition: 0.3s; }
.nav-item:hover { color: #fff; }
.nav-btn {
    text-decoration: none;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white; padding: 10px 24px; border-radius: 30px;
    font-weight: 700; font-size: 14px;
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.4);
    transition: 0.3s;
}
.nav-btn:hover { box-shadow: 0 6px 20px rgba(168, 85, 247, 0.6); transform: translateY(-2px); }

/* --- HERO --- */
.hero {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 60px 8%;
    min-height: 80vh;
}
.hero-content { flex: 1; min-width: 320px; z-index: 2; }
.badge {
    background: rgba(6, 182, 212, 0.1); color: var(--cyan);
    padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 700;
    border: 1px solid rgba(6, 182, 212, 0.3);
}

h1 {
    font-size: 4rem; line-height: 1.1; margin: 25px 0; font-weight: 900;
}
.gradient-text {
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.subtitle { font-size: 1.15rem; color: var(--text-muted); margin-bottom: 40px; max-width: 550px; }

.cta-group { display: flex; gap: 15px; }
.cta-primary {
    background: #fff; color: #000; padding: 14px 35px; border-radius: 12px;
    text-decoration: none; font-weight: 800; transition: 0.3s;
    display: flex; align-items: center; gap: 10px;
}
.cta-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(255,255,255,0.15); }
.cta-secondary {
    padding: 14px 35px; border-radius: 12px; text-decoration: none; font-weight: 700;
    color: #fff; border: 1px solid var(--glass-border); background: var(--glass);
    transition: 0.3s;
}
.cta-secondary:hover { background: rgba(255,255,255,0.1); }

/* --- VISUAL (TERMINAL) --- */
.hero-visual { flex: 1; display: flex; justify-content: center; position: relative; }
.terminal-mockup {
    width: 400px; padding: 25px; border-radius: 16px;
    background: rgba(10, 10, 15, 0.8);
    border: 1px solid var(--glass-border);
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    position: relative; overflow: hidden;
}
.window-controls { display: flex; gap: 8px; margin-bottom: 20px; }
.window-controls span { width: 12px; height: 12px; border-radius: 50%; }
.red { background: #ef4444; } .yellow { background: #f59e0b; } .green { background: #22c55e; }

.code-content { font-family: 'Menlo', monospace; font-size: 14px; color: #cbd5e1; direction: ltr; }
.cmd { color: var(--accent); margin-right: 8px; }
.success { color: #22c55e; }
.indent { margin-left: 15px; margin-top: 5px; opacity: 0.8; }
.blink { animation: blink 1s infinite; font-weight: bold; color: var(--cyan); }
@keyframes blink { 50% { opacity: 0; } }

/* Scanline Effect */
.scan-line {
    position: absolute; top: 0; left: 0; width: 100%; height: 2px;
    background: rgba(6, 182, 212, 0.5);
    box-shadow: 0 0 10px var(--cyan);
    animation: scan 3s linear infinite;
    opacity: 0.3;
}
@keyframes scan { 0% { top: 0%; } 100% { top: 100%; } }

/* --- STATS STRIP (THE NEW PART) --- */
.stats-container {
    padding: 0 8%; margin-top: -40px; position: relative; z-index: 10;
}
.glass-strip {
    display: flex; justify-content: space-around; align-items: center;
    background: rgba(20, 20, 25, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}
.stat-box { text-align: center; }
.gradient-num {
    display: block; font-size: 2.5rem; font-weight: 900;
    background: linear-gradient(to bottom, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 5px;
}
.stat-label { color: var(--text-muted); font-size: 0.9rem; font-weight: 700; }
.divider { width: 1px; height: 50px; background: var(--glass-border); }

/* --- FEATURES --- */
.features { padding: 100px 8%; }
.section-title { text-align: center; font-size: 2.5rem; margin-bottom: 60px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 30px; }

.feature-card {
    background: linear-gradient(160deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.01) 100%);
    border: 1px solid var(--glass-border);
    padding: 35px; border-radius: 20px;
    transition: 0.4s; position: relative; overflow: hidden;
}
.feature-card:hover {
    border-color: rgba(168, 85, 247, 0.4);
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}
.feature-card:hover .icon-box { transform: scale(1.1) rotate(5deg); background: rgba(168, 85, 247, 0.2); }

.icon-box {
    width: 60px; height: 60px; background: rgba(255,255,255,0.05);
    border-radius: 14px; display: flex; align-items: center; justify-content: center;
    font-size: 28px; margin-bottom: 25px; transition: 0.4s;
}
.feature-card h3 { font-size: 1.4rem; margin: 0 0 10px 0; }
.feature-card p { color: var(--text-muted); line-height: 1.6; font-size: 0.95rem; }

/* --- ANIMATIONS UTILS --- */
.fade-in-up {
    animation: fadeInUp 0.8s ease-out forwards;
    opacity: 0; transform: translateY(30px);
}
.delay-200 { animation-delay: 0.2s; }
.delay-400 { animation-delay: 0.4s; }

@keyframes fadeInUp {
    to { opacity: 1; transform: translateY(0); }
}

.slide-down {
    animation: slideDown 0.8s ease-out forwards;
}
@keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

footer { text-align: center; padding: 50px; border-top: 1px solid var(--glass-border); color: var(--text-muted); margin-top: 50px; }

/* RESPONSIVE */
@media (max-width: 768px) {
    h1 { font-size: 2.5rem; }
    .glass-strip { flex-direction: column; gap: 30px; }
    .divider { width: 100%; height: 1px; }
    .hero-visual { display: none; } /* Hide terminal on mobile for cleaner look */
}

/* --- AUTH PAGES (LOGIN / REGISTER) --- */

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header .logo {
    text-decoration: none;
    color: #fff;
    display: block;
    margin-bottom: 5px;
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
}

/* FORM ELEMENTS */
.input-group {
    margin-bottom: 20px;
    text-align: right; /* RTL Alignment */
}

.input-group label {
    display: block;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 8px;
    font-weight: 700;
}

.input-group input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    color: #fff;
    padding: 14px;
    border-radius: 10px;
    font-size: 1rem;
    font-family: var(--font-tajawal);
    transition: 0.3s;
    box-sizing: border-box; /* Important for padding */
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 15px rgba(91, 33, 182, 0.3);
}

/* BUTTON */
.auth-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    padding: 16px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: 0.3s;
    margin-top: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.auth-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(168, 85, 247, 0.4);
}

/* FOOTER */
.auth-footer {
    text-align: center;
    margin-top: 25px;
    border-top: 1px solid var(--glass-border);
    padding-top: 20px;
}

.auth-footer p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
}

.auth-footer a {
    color: var(--cyan);
    text-decoration: none;
    font-weight: 700;
    margin-right: 5px;
    transition: 0.2s;
}

.auth-footer a:hover {
    color: #fff;
    text-decoration: underline;
}

/* --- AUTH & TABS STYLING --- */

.auth-body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.back-link {
    color: var(--text-muted);
    text-decoration: none;
    margin-bottom: 20px;
    font-size: 0.9rem;
    transition: 0.3s;
    align-self: flex-start; /* Aligns to right in RTL */
    margin-right: 10%; /* Matches container alignment */
}
.back-link:hover { color: #fff; transform: translateX(5px); }

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 35px;
    box-shadow: 0 30px 60px rgba(0,0,0,0.6);
}

.auth-header { text-align: center; margin-bottom: 25px; }
.auth-header .logo { display: flex; font-size: 28px; margin-bottom: 5px; }
.auth-subtitle { color: var(--text-muted); font-size: 0.9rem; margin: 0; }

/* TABS SWITCHER */
.tab-container {
    display: flex;
    background: rgba(0,0,0,0.3);
    padding: 5px;
    border-radius: 12px;
    margin-bottom: 25px;
    border: 1px solid var(--glass-border);
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-tajawal);
    font-weight: 700;
    transition: 0.3s;
}

.tab-btn.active {
    background: var(--glass-border);
    color: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

/* FORMS TOGGLE logic */
.auth-form { display: none; animation: fadeIn 0.4s ease; }
.auth-form.active { display: block; }

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

/* BUTTONS */
.accent-btn {
    background: linear-gradient(135deg, var(--cyan), #0891b2); /* Different color for register */
}

/* --- DASHBOARD STYLES --- */

.dashboard-container {
    padding: 40px 8%;
    max-width: 1200px;
    margin: 0 auto;
}

/* ADD FORM */
.control-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 25px;
    border-radius: 16px;
    margin-bottom: 40px;
    margin-top: 5pc;
}

.add-device-form {
    display: flex;
    gap: 15px;
}

.add-device-form input {
    flex: 1;
    background: #000;
    border: 1px solid var(--border-color);
    color: #fff;
    padding: 15px;
    border-radius: 8px;
    font-family: var(--font-tajawal);
}

.add-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 0 30px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
}
.add-btn:hover { background: var(--accent); }

/* GRID */
.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-muted);
    padding: 50px;
    border: 2px dashed var(--border-color);
    border-radius: 16px;
}

/* DEVICE CARD */
.device-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    position: relative;
    transition: 0.3s;
}

.device-card:hover { transform: translateY(-5px); border-color: var(--primary); }

.card-header {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.status-indicator {
    width: 10px; height: 10px; border-radius: 50%;
    margin-left: 10px;
    box-shadow: 0 0 5px currentColor;
}
.status-indicator.online { background: #22c55e; color: #22c55e; }
.status-indicator.offline { background: #ef4444; color: #ef4444; opacity: 0.5; box-shadow: none; }

.device-name { margin: 0; font-size: 1.1rem; flex: 1; }

.delete-icon {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    transition: 0.2s;
}
.delete-icon:hover { color: #ef4444; }

.device-info {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    background: #000;
    padding: 10px;
    border-radius: 8px;
}
.device-info p { margin: 5px 0; display: flex; justify-content: space-between; }
.mono { font-family: monospace; color: var(--accent); }
.text-green { color: #22c55e; } .text-red { color: #ef4444; }

/* ACTIONS */
.device-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.cmd-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-family: var(--font-tajawal);
    font-weight: 700;
    cursor: pointer;
    font-size: 0.8rem;
    transition: 0.2s;
}

.btn-off { background: rgba(239, 68, 68, 0.15); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3); }
.btn-off:hover { background: #ef4444; color: #fff; }

.btn-restart { background: rgba(245, 158, 11, 0.15); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.3); }
.btn-restart:hover { background: #f59e0b; color: #fff; }

.code-btn {
    width: 100%;
    background: transparent;
    border: 1px dashed var(--text-muted);
    color: var(--text-muted);
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
}
.code-btn:hover { border-color: #fff; color: #fff; }

/* --- CUSTOM MODALS & TOASTS --- */

/* 1. TOAST NOTIFICATION (Small popup at bottom) */
.toast-container {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    pointer-events: none;
}

.toast {
    background: rgba(15, 15, 20, 0.95);
    border: 1px solid var(--border-color);
    color: #fff;
    padding: 12px 24px;
    border-radius: 50px;
    margin-top: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    transform: translateY(20px);
    transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* 2. MODAL OVERLAY (Dark background) */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* 3. MODAL BOX (The actual window) */
.modal-box {
    background: #0f1014;
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 450px;
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    transform: scale(0.9) translateY(20px);
    transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-align: center;
}

.modal-overlay.active .modal-box {
    transform: scale(1) translateY(0);
}

.modal-icon { font-size: 3rem; margin-bottom: 15px; display: block; }
.modal-title { margin: 0 0 10px 0; font-size: 1.5rem; color: #fff; }
.modal-text { color: var(--text-muted); margin-bottom: 25px; line-height: 1.5; font-size: 0.95rem; }

/* Modal Inputs (for Code Copy) */
.modal-input-box {
    background: #000;
    border: 1px solid var(--border-color);
    padding: 15px;
    border-radius: 8px;
    color: var(--accent);
    font-family: monospace;
    font-size: 0.85rem;
    word-break: break-all;
    text-align: left;
    margin-bottom: 20px;
    position: relative;
    height: 10pc;
    overflow: hidden;
}

/* Modal Buttons */
.modal-actions { display: flex; gap: 10px; justify-content: center; }
.btn-modal {
    padding: 12px 25px; border-radius: 8px; border: none; 
    font-weight: 700; cursor: pointer; font-family: var(--font-tajawal);
    transition: 0.2s; flex: 1;
}
.btn-primary { margin-top: 5px; background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--accent); }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-cancel { background: transparent; border: 1px solid var(--border-color); color: var(--text-muted); }
.btn-cancel:hover { border-color: #fff; color: #fff; }

/* --- SETTINGS PAGE --- */

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-top: 5pc;
}

.settings-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 30px;
    height: fit-content;
    border: 2px #2e1845 solid;
}

.card-header-simple h3 { margin: 0 0 10px 0; color: #fff; font-size: 1.2rem; }
.desc { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 20px; line-height: 1.5; }

/* Profile Info Rows */
.info-row {
    display: flex;
    justify-content: space-between;
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color);
}
.info-row:last-child { border-bottom: none; }
.info-row .label { color: var(--text-muted); }
.info-row .value { color: #fff; font-weight: 700; }

/* Status Badges */
.pin-status { margin-bottom: 20px; font-weight: 700; }
.status-badge { padding: 5px 10px; border-radius: 6px; font-size: 0.85rem; margin-right: 10px; }
.status-badge.green { background: rgba(34, 197, 94, 0.2); color: #4ade80; }
.status-badge.gray { background: rgba(255, 255, 255, 0.1); color: var(--text-muted); }

.action-btn {
    background: var(--primary); /* Deep Purple */
    color: #fff;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-family: var(--font-tajawal);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.action-btn:hover {
    background: var(--accent); /* Bright Purple on hover */
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(168, 85, 247, 0.4);
}

/* Secondary Button (Outline style for PIN) */
.btn-secondary {
    background: transparent;
    border: 2px solid #2e1845; /* Matches your card border */
    color: var(--text-muted);
}

.btn-secondary:hover {
    border-color: var(--primary);
    color: #fff;
    background: rgba(91, 33, 182, 0.1);
}

/* --- PIN CARD STYLES --- */

.status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255,255,255,0.05);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.secure-text {
    font-family: monospace;
    letter-spacing: 3px;
    color: var(--text-muted);
}

.split-inputs {
    display: flex;
    gap: 10px;
}

.pin-input {
    flex: 2;
    background: #000;
    border: 1px solid var(--border-color);
    color: #fff;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    font-size: 1.1rem;
    letter-spacing: 2px;
}

.divider-line {
    height: 1px;
    background: var(--border-color);
    margin: 20px 0;
}

.input-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 8px;
}

/* Danger Button (Outline) */
.btn-danger-outline {
    background: transparent;
    border: 1px solid #ef4444;
    color: #ef4444;
    width: 100%;
}
.btn-danger-outline:hover {
    background: #ef4444;
    color: white;
    box-shadow: 0 5px 15px rgba(239, 68, 68, 0.3);
}

/* --- PIN MODAL INPUT --- */
.modal-pin-input {
    background: #000;
    border: 1px solid var(--border-color);
    color: #fff;
    padding: 15px;
    border-radius: 12px;
    font-size: 1.5rem; /* Big text */
    text-align: center;
    letter-spacing: 10px; /* Space out the dots/numbers */
    width: 60%;
    margin-top: 15px;
    outline: none;
    transition: 0.3s;
}

.modal-pin-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(91, 33, 182, 0.3);
}

/* Add this with your other button styles */
.btn-ping { 
    background: rgba(6, 182, 212, 0.15); 
    color: var(--cyan); 
    border: 1px solid rgba(6, 182, 212, 0.3); 
}
.btn-ping:hover { 
    background: var(--cyan); 
    color: #000; 
}

.nav-links {
    display: flex;
    align-items: center;
    flex-direction: row;
    text-align: center;
    margin-right: 5px;
}

/* --- Pending Status Styles --- */
.status-indicator.pending { 
    background: #f59e0b; /* Amber/Yellow */
    color: #f59e0b; 
    box-shadow: 0 0 5px currentColor; 
}
.text-yellow { 
    color: #f59e0b; 
}

.faq-icon-svg { opacity: 0.9; flex-shrink: 0; }

.icon {
    width: 45px; height: 445px;
    fill: none; stroke: currentColor;
    stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
    vertical-align: middle;
}

.madeby {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 400;
}


/* --- REMEMBER ME CHECKBOX STYLING --- */
.remember-container {
    margin-bottom: 20px;
    text-align: right; /* RTL support */
}

.custom-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

/* Hide the default browser checkbox */
.custom-checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

/* Create a custom box */
.checkmark {
    height: 20px;
    width: 20px;
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 5px;
    position: relative;
    transition: 0.2s;
}

.custom-checkbox:hover .checkmark {
    border-color: var(--primary);
}

/* When checked */
.custom-checkbox input:checked ~ .checkmark {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* The tick mark */
.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.custom-checkbox input:checked ~ .checkmark:after {
    display: block;
}

.custom-checkbox .checkmark:after {
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.label-text {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.custom-checkbox input:checked ~ .label-text {
    color: #fff;
}

/* --- UPDATED BUTTON STYLES (ICONS ONLY) --- */

.device-actions.icon-row {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
}

.cmd-btn.icon-btn {
    flex: 1;
    height: 50px; /* Make them square/tall enough for touch */
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    transition: all 0.2s ease;
}

/* SVG Icon Styling */
.cmd-btn .feather {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Hover Effects (Lift up slightly) */
.cmd-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

/* --- COLORS --- */

/* Off (Existing) */
.btn-off { background: rgba(239, 68, 68, 0.15); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3); }
.btn-off:hover { background: #ef4444; color: #fff; }

/* Restart (Existing) */
.btn-restart { background: rgba(245, 158, 11, 0.15); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.3); }
.btn-restart:hover { background: #f59e0b; color: #fff; }

/* Ping (Existing) */
.btn-ping { background: rgba(6, 182, 212, 0.15); color: var(--cyan); border: 1px solid rgba(6, 182, 212, 0.3); }
.btn-ping:hover { background: var(--cyan); color: #fff; }

/* SLEEP (NEW) - Purple/Indigo */
.btn-sleep { 
    background: rgba(139, 92, 246, 0.15); 
    color: #a78bfa; 
    border: 1px solid rgba(139, 92, 246, 0.3); 
}
.btn-sleep:hover { 
    background: #8b5cf6; 
    color: #fff; 
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.4);
}

/* --- POP-UP TOOLTIP BUTTONS --- */

.device-actions.icon-row {
    display: flex;
    gap: 15px; /* More space between buttons */
    margin-bottom: 20px;
    justify-content: space-between; /* Spread them out evenly */
}

.cmd-btn.icon-btn {
    flex: 1;
    height: 55px; /* Nice big touch target */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative; /* Crucial for positioning the tooltip */
    /* IMPORTANT: Do NOT use overflow: hidden here, or the pop-up gets cut off */
}

/* Icon Style */
.cmd-btn .feather {
    width: 26px;
    height: 26px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* --- THE TOOLTIP (POP OUT) --- */
.tooltip {
    position: absolute;
    bottom: 120%; /* Pushes it ABOVE the button */
    left: 50%;
    transform: translateX(-50%) scale(0.8); /* Center horizontally */
    
    background: rgba(0, 0, 0, 0.9); /* Dark background */
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
    pointer-events: none; /* Mouse ignores it */
    
    opacity: 0; /* Hidden by default */
    visibility: hidden;
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 5px 15px rgba(0,0,0,0.4);
    z-index: 10;
}

/* Little Triangle Arrow below the tooltip */
.tooltip::after {
    content: '';
    position: absolute;
    top: 100%; /* Bottom of tooltip */
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: rgba(0, 0, 0, 0.9) transparent transparent transparent;
}

/* --- HOVER EFFECTS --- */

/* 1. Lift the button */
.cmd-btn.icon-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

/* 2. Show the Tooltip (Pop Up) */
.cmd-btn.icon-btn:hover .tooltip {
    opacity: 1;
    visibility: visible;
    bottom: 135%; /* Moves up slightly */
    transform: translateX(-50%) scale(1);
}

/* --- BUTTON COLORS (Retaining your theme) --- */

.btn-off { background: rgba(239, 68, 68, 0.1); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.2); }
.btn-off:hover { background: #ef4444; color: #fff; border-color: #ef4444; }

.btn-restart { background: rgba(245, 158, 11, 0.1); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.2); }
.btn-restart:hover { background: #f59e0b; color: #fff; border-color: #f59e0b; }

.btn-sleep { background: rgba(139, 92, 246, 0.1); color: #a78bfa; border: 1px solid rgba(139, 92, 246, 0.2); }
.btn-sleep:hover { background: #8b5cf6; color: #fff; border-color: #8b5cf6; }

.btn-ping { background: rgba(6, 182, 212, 0.1); color: var(--cyan); border: 1px solid rgba(6, 182, 212, 0.2); }
.btn-ping:hover { background: var(--cyan); color: #fff; border-color: var(--cyan); }

/* --- TERMINAL LOG VIEWER --- */
.terminal-window {
    background: #0a0a0f;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 20px;
    font-family: 'Menlo', 'Consolas', monospace;
    font-size: 0.85rem;
    height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column-reverse; /* Newest at bottom like a real terminal */
    box-shadow: inset 0 0 20px rgba(0,0,0,0.8);
    margin-top: 15px;
    position: relative;
}

/* Custom Scrollbar for Terminal */
.terminal-window::-webkit-scrollbar { width: 8px; }
.terminal-window::-webkit-scrollbar-track { background: #000; }
.terminal-window::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }

.log-entry {
    display: flex;
    gap: 15px;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    animation: fadeIn 0.3s ease;
}

.log-time { color: #64748b; min-width: 140px; }
.log-type { font-weight: bold; min-width: 80px; text-transform: uppercase; }
.log-msg { color: #e2e8f0; flex: 1; }

/* Log Colors */
.type-command { color: var(--cyan); }
.type-success { color: #22c55e; } /* Green */
.type-status { color: #f59e0b; }  /* Orange */
.type-error { color: #ef4444; }   /* Red */

/* Action Button Container Update */
.card-footer-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

/* --- CYBER TERMINAL STYLES --- */

/* The Modal Box itself */
.modal-box.cyber-theme {
    background: #050505;
    border: 1px solid var(--glass-border);
    box-shadow: 0 0 30px rgba(6, 182, 212, 0.15); /* Cyan Glow */
    max-width: 700px;
    width: 95%;
    overflow: hidden;
    position: relative;
}

/* Header strip */
.terminal-header {
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid #333;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.terminal-title {
    font-family: 'Courier New', monospace;
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.live-dot {
    width: 8px; height: 8px; background: #22c55e;
    border-radius: 50%; box-shadow: 0 0 8px #22c55e;
    animation: blink 2s infinite;
}

/* The Log Window (Screen) */
.terminal-window {
    background: #020202;
    height: 350px;
    overflow-y: auto;
    padding: 20px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9rem;
    position: relative;
    
    /* CRT Scanline Effect */
    background-image: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    background-size: 100% 2px, 3px 100%;
}

/* Scrollbar Styling */
.terminal-window::-webkit-scrollbar { width: 6px; }
.terminal-window::-webkit-scrollbar-track { background: #000; }
.terminal-window::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }

/* Log Item Styling */
.log-entry {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    transition: background 0.2s;
}

.log-entry:hover { background: rgba(255,255,255,0.02); }

/* Columns */
.log-time {
    color: #475569;
    font-size: 0.8rem;
    min-width: 80px;
    padding-top: 2px;
}

.log-icon {
    width: 18px; height: 18px;
    flex-shrink: 0;
}

.log-content {
    color: #cbd5e1;
    line-height: 1.4;
    flex: 1;
}

/* Event Specific Colors */
.evt-command { color: var(--cyan); }   /* Blue for User Actions */
.evt-success { color: #22c55e; }       /* Green for Success */
.evt-error   { color: #ef4444; }       /* Red for Errors */
.evt-status  { color: #f59e0b; }       /* Orange for Connection */

/* Footer Actions */
.terminal-footer {
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.02);
    border-top: 1px solid #333;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn-icon-text {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 16px; border-radius: 6px;
    font-family: var(--font-tajawal); font-size: 0.9rem; font-weight: 700;
    cursor: pointer; border: 1px solid transparent; background: transparent;
    transition: 0.2s;
}

.btn-refresh {
    color: var(--cyan); border-color: rgba(6, 182, 212, 0.3);
    background: rgba(6, 182, 212, 0.05);
}
.btn-refresh:hover { background: rgba(6, 182, 212, 0.15); box-shadow: 0 0 15px rgba(6, 182, 212, 0.2); }

.btn-close { color: var(--text-muted); }
.btn-close:hover { color: #fff; }

/* Loading State */
.typing-cursor::after {
    content: '▋';
    animation: blink 1s infinite;
    color: var(--cyan);
    margin-left: 5px;
}

/* --- NEW ACTION BUTTONS (GRID LAYOUT) --- */

/* Container to split buttons 50/50 */
.card-actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Base Cyber Button */
.cyber-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px;
    border-radius: 10px;
    font-family: var(--font-tajawal);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

/* 1. LINK BUTTON (Cyan - For Setup) */
.cyber-btn.link {
    background: rgba(6, 182, 212, 0.05);
    border: 1px solid rgba(6, 182, 212, 0.3);
    color: #22d3ee;
}

.cyber-btn.link:hover {
    background: rgba(6, 182, 212, 0.15);
    border-color: #22d3ee;
    box-shadow: 0 0 20px rgba(6, 182, 212, 0.25);
    transform: translateY(-2px);
}

/* 2. LOGS BUTTON (Purple - For Terminal) */
.cyber-btn.logs {
    background: rgba(168, 85, 247, 0.05);
    border: 1px solid rgba(168, 85, 247, 0.3);
    color: #d8b4fe;
}

.cyber-btn.logs:hover {
    background: rgba(168, 85, 247, 0.15);
    border-color: #d8b4fe;
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.25);
    transform: translateY(-2px);
}

/* Icon Sizing */
.cyber-btn svg {
    width: 18px;
    height: 18px;
    stroke-width: 2.5px;
}

.social-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    transition: 0.3s;
    font-size: 0.9rem;
}
.social-btn:hover {
    background: rgba(255,255,255,0.1);
    border-color: var(--primary);
    transform: translateY(-2px);
}

/* --- NEW FLOATING NAVBAR --- */
.navbar-container {
    position: fixed;
    top: 20px;
    left: 0; 
    right: 0;
    display: flex;
    justify-content: center;
    z-index: 1000;
    padding: 0 20px;
}

.navbar {
    width: 100%;
    max-width: 1200px;
    background: rgba(5, 5, 8, 0.75); /* Darker, more opaque */
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 12px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

/* Hide Nav on Scroll down (Optional JS required) or just hover effect */
.navbar:hover {
    background: rgba(5, 5, 8, 0.9);
    border-color: rgba(168, 85, 247, 0.3); /* Purple Glow on hover */
    box-shadow: 0 15px 50px rgba(91, 33, 182, 0.15);
}

.logo { 
    font-size: 22px; 
    font-weight: 900; 
    letter-spacing: -1px; 
    color: #fff;
    display: flex;
    align-items: center;
    text-decoration: none;
    gap: 5px;
}

/* --- NAV ITEMS GROUP --- */
.nav-group {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-item { 
    text-decoration: none; 
    color: var(--text-muted); 
    font-weight: 700; 
    font-size: 0.95rem;
    transition: 0.3s; 
    position: relative;
}

.nav-item:hover { color: #fff; }

/* Active State Dot */
.nav-item.active::after {
    content: '';
    position: absolute;
    bottom: -5px; left: 50%; transform: translateX(-50%);
    width: 4px; height: 4px; background: var(--cyan);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--cyan);
}

.nav-btn {
    text-decoration: none;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white; 
    padding: 10px 24px; 
    border-radius: 14px; /* Softer corners */
    font-weight: 700; 
    font-size: 14px;
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.4);
    transition: 0.3s;
}
.nav-btn:hover { 
    box-shadow: 0 6px 20px rgba(168, 85, 247, 0.6); 
    transform: translateY(-2px); 
}

/* --- NOTIFICATION SYSTEM --- */

.notif-wrapper {
    position: relative;
}

.notif-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    width: 40px; height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.3s;
    display: none;
}

.notif-btn:hover, .notif-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
}

.notif-badge {
    position: absolute;
    top: -2px; right: -2px;
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: bold;
    width: 16px; height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #000; /* Create separation */
    animation: bounceIn 0.5s;
}

/* THE DROPDOWN */
.notif-dropdown {
    position: absolute;
    top: 55px; 
    left: 0; /* Aligned left because RTL */
    width: 320px;
    background: #0a0a0f;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    z-index: 1100;
}

.notif-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.notif-header {
    padding: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
    background: rgba(255,255,255,0.02);
}

.mark-read {
    font-size: 0.75rem;
    color: var(--cyan);
    cursor: pointer;
}
.mark-read:hover { text-decoration: underline; }

.notif-list {
    max-height: 300px;
    overflow-y: auto;
}

/* Individual Item */
.notif-item {
    display: flex;
    gap: 12px;
    padding: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    transition: 0.2s;
    cursor: pointer;
}
.notif-item:hover { background: rgba(255,255,255,0.03); }
.notif-item:last-child { border-bottom: none; }

.notif-icon {
    width: 35px; height: 35px;
    background: rgba(168, 85, 247, 0.1);
    color: var(--accent);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.notif-icon.ad { background: rgba(6, 182, 212, 0.1); color: var(--cyan); }
.notif-icon.alert { background: rgba(239, 68, 68, 0.1); color: #ef4444; }

.notif-content h4 { margin: 0 0 4px 0; font-size: 0.9rem; color: #fff; }
.notif-content p { margin: 0; font-size: 0.8rem; color: var(--text-muted); line-height: 1.4; }
.notif-time { display: block; margin-top: 5px; font-size: 0.7rem; color: #64748b; }

@keyframes bounceIn {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* --- RESPONSIVE / MOBILE OPTIMIZATION --- */

@media (max-width: 768px) {
    /* 2. Hide Text Labels, Show Icons Only */
    .nav-text {
        display: none; /* Hides "Dashboard", "Home" text */
    }
    
    .nav-icon {
        display: block !important; /* Forces icons to show */
        font-size: 1.2rem;
    }

    /* 3. Adjust Spacing */
    .nav-group {
        gap: 12px; 
    }

    .nav-item {
        padding: 8px; 
        color: var(--text-muted);
        display: flex;
        align-items: center;
        justify-content: center;
    }


    .notif-dropdown {
        position: fixed; 
        top: 80px;
        left: 50%;
        transform: translateX(-50%) translateY(10px);
        width: 90%;
        max-width: 350px;
    }
    
    .notif-dropdown.show {
        transform: translateX(-50%) translateY(0);
    }
    
}

.nav-icon { display: none; }
@media (max-width: 768px) {
    .nav-icon { display: block; }
}

@media (max-width: 768px) {
    
    /* 1. Bar Container */
    .navbar-container {
        top: 10px;
        padding: 0 8px;
    }
    
    
    .navbar {
        padding: 0 10px; 
        height: 60px;   
        border-radius: 16px;
        justify-content: space-between; 
    }


    .logo-text { 
        display: none !important; 
    }
    
    .logo-img {
        display: block !important;
        height: 38px; /* Fits perfectly inside the 60px bar */
        width: auto;  /* Maintains aspect ratio */
        border-radius: 8px; /* Optional: adds nice rounded corners to the icon */
    }
    
    /* 2. Reset Logo Container Margins */
    .logo {
        margin-left: 0;
        flex-shrink: 0;
        display: flex;
        align-items: center;
    }

    .nav-group {
        gap: 2px; 
    }
    .notif-btn {
        display: none;
    }
    .nav-item, .notif-btn {
        padding: 8px; 
        border-radius: 10px;
        min-width: 36px; 
        align-items: center;
        justify-content: center;
    }

    .nav-text { display: none !important; }
    .nav-icon { display: block !important; line-height: 0; }

    /* Keep icons readable size */
    .nav-icon svg, .notif-btn svg {
        width: 22px !important;
        height: 22px !important;
    }

    .notif-dropdown {
        position: fixed;
        top: 80px;
        left: 50%;
        transform: translateX(-50%) translateY(10px);
        width: 90%;
        max-width: 350px;
        z-index: 2000;
    }
    .notif-dropdown.show {
        transform: translateX(-50%) translateY(0);
    }

    .hero-visual { display: none; }
    h1 { font-size: 2.2rem; }
}

/* DEFAULT (Desktop): Show text, hide image */
.logo-text { display: block; }
.logo-img { display: none; }

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

/* Ensure inputs inside the row share space equally */
.form-row .input-group {
    flex: 1;
    margin-bottom: 0; /* Remove default margin to fit row */
}

/* Compact the security header */
.security-header {
    border-top: 1px solid rgba(255,255,255,0.1);
    margin: 15px 0;
    padding-top: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.security-header p {
    font-size: 0.8rem;
    color: var(--cyan);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Mobile: Stack them back to one column for small screens */
@media (max-width: 480px) {
    .form-row {
        flex-direction: column;
        gap: 15px;
    }
}