/* ==========================================================================
   Modern Minimal School System Portal - Main Stylesheet
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Prompt:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  /* Color Palette - Clean Professional Blue & Slate Tone */
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.85);
  
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-subtle: #dbeafe;
  --primary-dark: #1e3a8a;
  
  --accent: #3b82f6;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --border-light: #e2e8f0;
  --border-focus: #93c5fd;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 25px -5px rgba(37, 99, 235, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --shadow-hover: 0 20px 30px -10px rgba(37, 99, 235, 0.15), 0 10px 15px -5px rgba(0, 0, 0, 0.05);
  
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;
  
  --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Dark Mode Overrides */
body.dark-mode {
  --bg-main: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --bg-glass: rgba(30, 41, 59, 0.88);
  
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: #1e293b;
  --primary-subtle: #1e3a8a;
  --primary-dark: #93c5fd;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  
  --border-light: #334155;
  --border-focus: #3b82f6;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
  --shadow-hover: 0 20px 30px -10px rgba(59, 130, 246, 0.25);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Prompt', 'Plus Jakarta Sans', sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}

/* Background Animated Gradient Blobs */
.bg-decoration {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.45;
  animation: floatBlob 20s infinite alternate ease-in-out;
}

.blob-1 {
  top: -10%;
  left: 15%;
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, rgba(147,197,253,0.8) 0%, rgba(37,99,235,0.2) 100%);
}

.blob-2 {
  bottom: -15%;
  right: 10%;
  width: 550px;
  height: 550px;
  background: radial-gradient(circle, rgba(191,219,254,0.6) 0%, rgba(29,78,216,0.15) 100%);
  animation-delay: -7s;
}

@keyframes floatBlob {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, 30px) scale(1.08); }
  100% { transform: translate(-30px, -40px) scale(0.95); }
}

/* Container */
.app-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 24px 60px 24px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Header Section */
.main-header {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px 32px;
  margin-bottom: 32px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  transition: var(--transition-normal);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 20px;
}

.school-logo-container {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: var(--primary-light);
  border: 2px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-bounce);
  flex-shrink: 0;
}

.school-logo-container:hover {
  transform: scale(1.05) rotate(2deg);
}

.school-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 6px;
}

.brand-info h1 {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.brand-info p {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 4px;
}

/* Header Controls & Status */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cloud-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  box-shadow: var(--shadow-sm);
}

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

.status-dot.offline {
  background-color: #f59e0b;
  box-shadow: 0 0 10px #f59e0b;
}

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

.btn-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.btn-icon:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--border-focus);
  transform: translateY(-2px);
}

.btn-admin {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 14px;
  background: var(--primary);
  color: #ffffff;
  border: none;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
  transition: var(--transition-fast);
}

.btn-admin:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

/* Control Bar (Search & Categories) */
.control-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 280px;
  max-width: 480px;
}

.search-box input {
  width: 100%;
  padding: 12px 18px 12px 48px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-fast);
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.search-box svg {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  transition: var(--transition-fast);
}

.search-box input:focus + svg {
  color: var(--primary);
}

.category-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.category-pills::-webkit-scrollbar {
  display: none;
}

.pill-btn {
  padding: 8px 18px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: var(--transition-fast);
}

.pill-btn:hover {
  color: var(--primary);
  border-color: var(--border-focus);
  background: var(--primary-light);
}

.pill-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.25);
}

/* System Cards Grid */
.system-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 22px;
  margin-bottom: 40px;
}

/* System Card Item */
.system-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 28px 20px 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  text-decoration: none;
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-bounce);
  cursor: pointer;
  overflow: hidden;
  user-select: none;
}

.system-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, #2563eb, #60a5fa);
  opacity: 0;
  transition: var(--transition-fast);
}

.system-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-hover);
  border-color: var(--border-focus);
  background: var(--bg-card-hover);
}

.system-card:hover::before {
  opacity: 1;
}

.card-icon-wrapper {
  width: 110px;
  height: 110px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: var(--transition-bounce);
}

.system-card:hover .card-icon-wrapper {
  transform: scale(1.08);
}

.card-icon-wrapper svg,
.card-icon-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.card-title {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.4;
  word-break: break-word;
  transition: var(--transition-fast);
}

.system-card:hover .card-title {
  color: var(--primary);
}

.card-category-tag {
  margin-top: 10px;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary);
  opacity: 0.9;
}

.external-arrow {
  position: absolute;
  top: 12px;
  right: 12px;
  opacity: 0;
  transform: translate(-4px, 4px);
  color: var(--primary);
  transition: var(--transition-fast);
}

.system-card:hover .external-arrow {
  opacity: 1;
  transform: translate(0, 0);
}

/* Empty Grid State */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-light);
  color: var(--text-muted);
}

.empty-state svg {
  width: 56px;
  height: 56px;
  color: var(--text-light);
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-main);
}

/* Footer */
.main-footer {
  margin-top: auto;
  text-align: center;
  padding: 24px 0;
  border-top: 1px solid var(--border-light);
  color: var(--text-muted);
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

/* Modal Overlay & Base */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  transform: scale(0.92) translateY(20px);
  transition: var(--transition-bounce);
}

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

.modal-card.wide {
  max-width: 960px;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 10;
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.close-btn:hover {
  background: var(--primary-light);
  color: var(--text-main);
}

.modal-body {
  padding: 24px;
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 8px;
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--bg-main);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition-fast);
}

.form-control:focus {
  border-color: var(--primary);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Admin Tabs */
.admin-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 24px;
  gap: 8px;
  overflow-x: auto;
}

.tab-btn {
  padding: 12px 20px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab-btn:hover {
  color: var(--primary);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Admin Items Table & List */
.admin-item-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  background: var(--bg-main);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.admin-item-row.dragging {
  opacity: 0.5;
  border-style: dashed;
}

.admin-item-info {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
}

.drag-handle {
  cursor: grab;
  color: var(--text-light);
  display: flex;
  align-items: center;
}

.drag-handle:active {
  cursor: grabbing;
}

.admin-item-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  flex-shrink: 0;
}

.admin-item-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
}

.admin-item-link {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition-fast);
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-main);
  border-color: var(--border-light);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: var(--border-light);
}

.btn-danger {
  background: #ef4444;
  color: #ffffff;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
  border-radius: 8px;
}

/* Icon Selection Grid in Form */
.icon-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 10px;
  max-height: 180px;
  overflow-y: auto;
  padding: 8px;
  background: var(--bg-main);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin-top: 8px;
}

.icon-picker-option {
  width: 60px;
  height: 60px;
  border-radius: 10px;
  border: 2px solid var(--border-light);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 6px;
  transition: var(--transition-fast);
}

.icon-picker-option:hover {
  border-color: var(--border-focus);
}

.icon-picker-option.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 2px var(--primary);
}

/* Cloud DB Config Status Box */
.cloud-config-box {
  background: var(--primary-light);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 20px;
}

/* Responsive Adjustments for All Modern Devices */
@media (max-width: 1024px) {
  .app-container {
    max-width: 100%;
    padding: 20px 20px 50px 20px;
  }

  .system-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 18px;
  }
}

@media (max-width: 768px) {
  .app-container {
    padding: 14px 14px 40px 14px;
  }

  .main-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 18px 20px;
    gap: 16px;
  }

  .brand-section {
    gap: 14px;
  }

  .school-logo-container {
    width: 60px;
    height: 60px;
    border-radius: 16px;
  }

  .brand-info h1 {
    font-size: 1.35rem;
  }

  .brand-info p {
    font-size: 0.88rem;
  }
  
  .header-actions {
    width: 100%;
    justify-content: space-between;
    margin-top: 4px;
    padding-top: 14px;
    border-top: 1px solid var(--border-light);
  }
  
  .control-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  
  .search-box {
    max-width: 100%;
  }
  
  .system-grid {
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 14px;
  }

  .system-card {
    padding: 22px 14px 18px 14px;
  }

  .card-icon-wrapper {
    width: 82px;
    height: 82px;
    margin-bottom: 10px;
  }
  
  .card-title {
    font-size: 0.86rem;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .main-footer {
    flex-direction: column;
    text-align: center;
    gap: 8px;
    font-size: 0.82rem;
  }
}

@media (max-width: 480px) {
  .system-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .system-card {
    padding: 18px 10px 14px 10px;
    border-radius: 14px;
  }

  .card-icon-wrapper {
    width: 72px;
    height: 72px;
    margin-bottom: 8px;
  }

  .card-title {
    font-size: 0.82rem;
    line-height: 1.3;
  }

  .card-category-tag {
    font-size: 0.7rem;
    padding: 2px 8px;
  }

  .btn-admin {
    padding: 8px 14px;
    font-size: 0.84rem;
  }
}
