/* =============================================
   PREDICTIVE MAINTENANCE SYSTEM — STYLESHEET
   Arab Open University, Bahrain
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@400;500;600;700&family=Inter:wght@300;400;500&display=swap');

/* ---- CSS Variables ---- */
:root {
  --bg-base:       #0D1B2E;
  --bg-deep:       #091525;
  --bg-card:       #1B2A4A;
  --bg-card-hover: #243B5E;
  --bg-sidebar:    #111E33;
  --bg-header:     #0F1E34;
  --accent:        #4A9EFF;
  --accent-dim:    rgba(74, 158, 255, 0.15);
  --accent-glow:   rgba(74, 158, 255, 0.35);
  --text-primary:  #E8EEF7;
  --text-secondary:#8BA4C0;
  --text-muted:    #4A6080;
  --border:        rgba(74, 158, 255, 0.12);
  --border-strong: rgba(74, 158, 255, 0.3);
  --danger:        #FF6B6B;
  --success:       #4ECDC4;
  --warning:       #FFB347;
  --font-display:  'Rajdhani', sans-serif;
  --font-body:     'Inter', sans-serif;
  --sidebar-w:     240px;
  --header-h:      64px;
  --footer-h:      44px;
  --radius:        10px;
  --shadow:        0 4px 24px rgba(0,0,0,0.4);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body { font-family: var(--font-body); background: var(--bg-base); color: var(--text-primary); min-height: 100vh; overflow-x: hidden; }
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }

/* =============================================
   LOGIN PAGE
   ============================================= */

body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-deep);
  position: relative;
  overflow: hidden;
}

/* Animated background grid */
.bg-grid {
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(74,158,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(74,158,255,0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  animation: gridDrift 20s linear infinite;
  z-index: 0;
}
@keyframes gridDrift {
  0% { transform: translate(0,0); }
  100% { transform: translate(48px, 48px); }
}

.bg-glow {
  position: fixed;
  width: 700px; height: 700px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(74,158,255,0.07) 0%, transparent 70%);
  top: -200px; left: -200px;
  animation: glowPulse 6s ease-in-out infinite;
  z-index: 0;
}
@keyframes glowPulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* Particles */
.particles { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.particle {
  position: absolute;
  width: 2px; height: 2px;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0;
  animation: floatUp var(--dur, 8s) var(--delay, 0s) infinite ease-in;
}
@keyframes floatUp {
  0% { opacity: 0; transform: translateY(100vh) scale(0); }
  10% { opacity: 0.6; }
  90% { opacity: 0.3; }
  100% { opacity: 0; transform: translateY(-20px) scale(1.5); }
}

/* Login wrapper */
.login-wrapper {
  position: relative; z-index: 10;
  display: flex;
  width: 900px; max-width: 96vw;
  min-height: 560px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6), 0 0 0 1px var(--border-strong);
  animation: fadeInUp 0.7s ease both;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Brand panel */
.login-brand {
  flex: 1;
  background: linear-gradient(145deg, #0F1E34 0%, #1B2A4A 60%, #0D1B2E 100%);
  padding: 3rem 2.5rem;
  display: flex;
  align-items: center;
  position: relative;
  overflow: hidden;
  border-right: 1px solid var(--border);
}
.login-brand::before {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(74,158,255,0.1), transparent 70%);
  bottom: -100px; right: -100px;
}

.brand-icon {
  width: 64px; height: 64px;
  margin-bottom: 1.5rem;
  animation: rotateSlow 12s linear infinite;
}
@keyframes rotateSlow {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.brand-title {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-primary);
  letter-spacing: 0.02em;
  margin-bottom: 0.5rem;
}
.brand-subtitle {
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.5rem;
}
.brand-divider {
  width: 40px; height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  margin-bottom: 1.5rem;
}
.brand-stats {
  display: flex; gap: 1.5rem;
  margin-bottom: 2rem;
}
.stat-item { display: flex; flex-direction: column; }
.stat-number {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.stat-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-top: 2px;
}
.brand-footer {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* Form panel */
.login-form-panel {
  width: 380px;
  background: var(--bg-card);
  padding: 3rem 2.5rem;
  display: flex;
  align-items: center;
}
.login-card { width: 100%; }

.lock-icon { width: 48px; height: 48px; margin-bottom: 1rem; }
.login-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}
.login-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 2rem;
}

/* Input groups */
.input-group { margin-bottom: 1.2rem; }
.input-group label {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.input-icon {
  position: absolute; left: 12px;
  width: 16px; height: 16px;
  pointer-events: none;
}
.input-wrapper input {
  width: 100%;
  padding: 0.75rem 2.8rem 0.75rem 2.5rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.input-wrapper input::placeholder { color: var(--text-muted); }
.input-wrapper input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  background: rgba(74,158,255,0.04);
}
.toggle-pass {
  position: absolute; right: 10px;
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  opacity: 0.6; transition: opacity 0.2s;
}
.toggle-pass:hover { opacity: 1; }
.toggle-pass svg { width: 16px; height: 16px; }

/* Error */
.error-msg {
  display: none;
  align-items: center;
  gap: 8px;
  background: rgba(255,107,107,0.1);
  border: 1px solid rgba(255,107,107,0.3);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  font-size: 0.8rem;
  color: var(--danger);
  margin-bottom: 1rem;
  animation: shake 0.4s ease;
}
.error-msg.show { display: flex; }
.error-msg svg { width: 16px; height: 16px; flex-shrink: 0; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* Login button */
.login-btn {
  width: 100%;
  padding: 0.85rem;
  background: linear-gradient(135deg, #2878D4, var(--accent));
  border-radius: var(--radius);
  color: white;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  margin-bottom: 1.2rem;
}
.login-btn::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
  opacity: 0; transition: opacity 0.2s;
}
.login-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 24px var(--accent-glow); }
.login-btn:hover::before { opacity: 1; }
.login-btn:active { transform: translateY(0); }
.btn-arrow { width: 18px; height: 18px; transition: transform 0.2s; }
.login-btn:hover .btn-arrow { transform: translateX(4px); }
.btn-loader { display: none; gap: 5px; }
.loader-dot {
  width: 6px; height: 6px;
  background: white; border-radius: 50%;
  animation: bounce 0.6s infinite alternate;
}
.loader-dot:nth-child(2) { animation-delay: 0.2s; }
.loader-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  from { transform: translateY(0); opacity: 0.5; }
  to   { transform: translateY(-6px); opacity: 1; }
}

/* Hint */
.login-hint {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
}
.login-hint svg { width: 14px; height: 14px; flex-shrink: 0; }
.login-hint strong { color: var(--text-secondary); }

/* =============================================
   APP PAGE (DASHBOARD)
   ============================================= */

body.app-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg-base);
}

/* Header */
.app-header {
  height: var(--header-h);
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 16px rgba(0,0,0,0.3);
}
.header-left, .header-right { display: flex; align-items: center; gap: 1rem; }
.sidebar-toggle {
  display: flex; flex-direction: column;
  gap: 5px; padding: 6px; border-radius: 6px;
  transition: background 0.2s;
}
.sidebar-toggle:hover { background: var(--accent-dim); }
.sidebar-toggle span {
  display: block; width: 20px; height: 2px;
  background: var(--text-secondary);
  border-radius: 2px;
  transition: all 0.3s;
}
.header-icon { width: 32px; height: 32px; }
.header-brand { display: flex; align-items: center; gap: 0.75rem; }
.header-title {
  font-family: var(--font-display);
  font-size: 1.1rem; font-weight: 600;
  color: var(--text-primary);
  display: block; line-height: 1.2;
}
.header-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
  display: block;
  letter-spacing: 0.05em;
}

.header-status {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.75rem; color: var(--success);
  background: rgba(78,205,196,0.08);
  border: 1px solid rgba(78,205,196,0.2);
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
}
.status-dot {
  width: 7px; height: 7px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(78,205,196,0.4); }
  50% { opacity: 0.8; box-shadow: 0 0 0 4px rgba(78,205,196,0); }
}

.header-user {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.82rem; color: var(--text-secondary);
}
.user-avatar {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, #2878D4, var(--accent));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700; font-size: 0.85rem;
  color: white;
}

.logout-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  transition: all 0.2s;
}
.logout-btn svg { width: 15px; height: 15px; }
.logout-btn:hover {
  background: rgba(255,107,107,0.1);
  border-color: rgba(255,107,107,0.4);
  color: var(--danger);
}

/* App body */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: transform 0.3s ease, width 0.3s ease;
  flex-shrink: 0;
}
.sidebar.collapsed { transform: translateX(calc(-1 * var(--sidebar-w))); width: 0; overflow: hidden; }

.sidebar-nav { padding: 1.2rem 0.75rem; }
.nav-section-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  padding: 0 0.5rem;
  margin-bottom: 0.5rem;
}

.nav-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.7rem 0.8rem;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
  margin-bottom: 2px;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--accent-dim); color: var(--accent); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }
.nav-indicator {
  position: absolute; right: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 0;
  background: var(--accent);
  border-radius: 2px 0 0 2px;
  transition: height 0.2s;
}
.nav-item.active .nav-indicator { height: 60%; }

.sidebar-info-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem;
  margin-top: 0.5rem;
}
.info-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.info-row:last-child { margin-bottom: 0; }
.info-label { font-size: 0.7rem; color: var(--text-muted); }
.info-val { font-size: 0.75rem; color: var(--text-secondary); font-family: var(--font-display); font-weight: 600; }
.info-val.online { color: var(--success); }

/* Main */
.app-main {
  flex: 1;
  overflow-y: auto;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
}

.page-content { display: none; flex-direction: column; gap: 1rem; flex: 1; animation: fadeIn 0.3s ease; }
.page-content.active { display: flex; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.page-header {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.page-title {
  font-family: var(--font-display);
  font-size: 1.6rem; font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.page-desc { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }
.page-badge {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.72rem; color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--border-strong);
  padding: 0.35rem 0.8rem;
  border-radius: 20px;
  white-space: nowrap;
}
.page-badge svg { width: 13px; height: 13px; }

/* Embed area */
.embed-container {
  flex: 1;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
  height: calc(100vh - var(--header-h) - var(--footer-h) - 140px);
  min-height: 600px;
  display: flex;
  flex-direction: column;
}

.embed-placeholder {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  min-height: 500px;
}
.embed-inner {
  text-align: center;
  max-width: 400px;
}
.embed-inner svg { width: 80px; height: 80px; margin-bottom: 1.2rem; opacity: 0.7; }
.embed-inner h3 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--text-primary);
  margin-bottom: 0.3rem;
}
.embed-inner p { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 0.5rem; }
.embed-note {
  font-size: 0.75rem !important;
  color: var(--text-muted) !important;
  background: rgba(255,255,255,0.03);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 0.8rem;
  margin-top: 1rem !important;
  line-height: 1.6;
}
.embed-note code {
  background: var(--accent-dim);
  color: var(--accent);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.75rem;
}
.embed-steps {
  display: flex; gap: 0.75rem;
  margin-top: 1.2rem;
  justify-content: center;
  flex-wrap: wrap;
}
.step {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.72rem; color: var(--text-secondary);
  background: var(--bg-card-hover);
  border: 1px solid var(--border);
  padding: 0.4rem 0.75rem;
  border-radius: 20px;
}
.step span {
  width: 16px; height: 16px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; font-weight: 700; color: white;
}

.power-bi-frame {
  width: 100%;
  height: 100%;
  flex: 1;
  min-height: 600px;
  border: none;
  display: block;
}
.hidden { display: none !important; }

/* About page */
.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.about-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  gap: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.about-card:hover {
  border-color: var(--border-strong);
  box-shadow: 0 4px 20px rgba(74,158,255,0.08);
}
.about-card.wide { grid-column: span 2; }
.about-card.highlight-card { border-color: rgba(74,158,255,0.25); background: linear-gradient(135deg, var(--bg-card), rgba(74,158,255,0.05)); }

.about-card-icon {
  width: 40px; height: 40px;
  background: var(--accent-dim);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.about-card-icon svg { width: 20px; height: 20px; }
.about-card-body h3 {
  font-family: var(--font-display);
  font-size: 1.05rem; font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}
.about-card-body p { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.7; }
.about-card-body ul { padding-left: 0; }
.about-card-body ul li {
  font-size: 0.82rem; color: var(--text-secondary);
  padding: 0.2rem 0;
  padding-left: 0.5rem;
  border-left: 2px solid var(--accent-dim);
  margin-bottom: 0.4rem;
}
.tech-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.3rem; }
.tag {
  background: var(--accent-dim);
  border: 1px solid var(--border-strong);
  color: var(--accent);
  font-size: 0.7rem;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  font-weight: 500;
}
/* CRISP-DM phases */
.crisp-phases { display: flex; flex-direction: column; gap: 0.45rem; margin-top: 0.4rem; }
.crisp-phase {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.45rem 0.6rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: background 0.2s, border-color 0.2s;
}
.crisp-phase:hover { background: var(--accent-dim); border-color: var(--border-strong); }
.phase-num {
  width: 22px; height: 22px;
  background: linear-gradient(135deg, #2878D4, var(--accent));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; font-weight: 700; color: white;
  flex-shrink: 0;
}
.phase-info { display: flex; flex-direction: column; }
.phase-name { font-size: 0.78rem; font-weight: 500; color: var(--text-primary); }
.phase-desc { font-size: 0.68rem; color: var(--text-muted); margin-top: 1px; }

.student-name {
  font-family: var(--font-display);
  font-size: 1.2rem !important;
  font-weight: 600 !important;
  color: var(--accent) !important;
  margin-bottom: 0.3rem;
}
.student-meta { font-size: 0.75rem !important; color: var(--text-muted) !important; }

/* Footer */
.app-footer {
  height: var(--footer-h);
  background: var(--bg-header);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  font-size: 0.68rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 768px) {
  .login-wrapper { flex-direction: column; }
  .login-brand { padding: 2rem; min-height: auto; }
  .login-form-panel { width: 100%; }
  .brand-title { font-size: 1.8rem; }
  .about-grid { grid-template-columns: 1fr; }
  .about-card.wide { grid-column: span 1; }
  .header-sub, .header-status { display: none; }
  .app-footer span:last-child { display: none; }

  body.login-page {
    overflow-y: auto !important;
    align-items: flex-start;
    padding: 0;
  }
  .login-wrapper {
    overflow-y: auto;
    height: auto;
    min-height: 100vh;
  }
  .bg-grid, .bg-glow, .particles {
    position: fixed;
  }
   /* Sidebar overlays content on mobile */
  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    height: calc(100vh - var(--header-h));
    z-index: 200;
    transform: translateX(0);
    transition: transform 0.3s ease;
  }
  .sidebar.collapsed {
    transform: translateX(calc(-1 * var(--sidebar-w)));
    width: var(--sidebar-w);
    overflow: hidden;
  }
}
