:root {
  --bg-color: #0d0d0d;
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-hover: rgba(255, 255, 255, 0.15);
  --primary: #9b51e0; /* Purple */
  --secondary: #bb6bd9; /* Lilac */
  --tertiary: #56ccf2; /* Blue */
  --danger: #eb5757;
  --text-main: #f2f2f2;
  --text-muted: #a0a0a0;
  --font-family: 'Inter', sans-serif;
  --border-radius: 12px;
  --transition-speed: 0.3s;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-family);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* Typography & Utils */
h1, h2, h3, h4 { font-weight: 600; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 2rem; }
.w-100 { width: 100%; }
.text-muted { color: var(--text-muted); }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }

/* Glassmorphism Panel */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  transition: all var(--transition-speed) ease;
}
.glass-panel:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

/* Animations */
.fade-in { animation: fadeIn 0.4s ease-in-out; }
.fade-in-up { animation: fadeInUp 0.4s ease-in-out; }

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

/* Buttons */
.btn {
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  border: none;
  font-family: var(--font-family);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-speed);
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  box-shadow: 0 4px 15px rgba(155, 81, 224, 0.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--secondary), var(--primary));
  box-shadow: 0 6px 20px rgba(155, 81, 224, 0.5);
  transform: translateY(-2px);
}
.btn-secondary {
  background: var(--glass-bg);
  color: var(--text-main);
  border: 1px solid var(--glass-border);
}
.btn-secondary:hover {
  background: var(--glass-hover);
}
.btn-danger {
  background: rgba(235, 87, 87, 0.1);
  color: var(--danger);
  border: 1px solid rgba(235, 87, 87, 0.3);
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

/* Forms */
.input-group { margin-bottom: 1rem; }
.input-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}
input[type="text"], input[type="password"], .url-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  font-family: var(--font-family);
  outline: none;
  transition: border-color var(--transition-speed);
}
input[type="text"]:focus, input[type="password"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(155, 81, 224, 0.1);
}

.password-wrapper {
  position: relative;
  width: 100%;
}
.toggle-password {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  filter: grayscale(1) opacity(0.7);
  transition: all var(--transition-speed);
}
.toggle-password:hover {
  filter: grayscale(0) opacity(1);
}

/* Login Screen */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100vh;
  background: radial-gradient(circle at top right, rgba(155, 81, 224, 0.15), transparent 40%),
              radial-gradient(circle at bottom left, rgba(86, 204, 242, 0.1), transparent 40%);
}
.login-box {
  width: 100%;
  max-width: 400px;
  padding: 2.5rem;
}
.logo-large { text-align: center; margin-bottom: 2rem; }
.logo-large h2 { font-size: 2.5rem; background: linear-gradient(to right, var(--text-main), var(--text-muted)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.logo-large span { background: linear-gradient(to right, var(--primary), var(--tertiary)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.error-msg { background: rgba(235,87,87,0.1); color: var(--danger); padding: 0.75rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem; text-align: center; border: 1px solid rgba(235,87,87,0.2); }

/* App Layout */
.app-container { display: flex; width: 100%; }

/* Sidebar */
.sidebar {
  width: 250px;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--glass-border);
  border-radius: 0;
  z-index: 10;
}
.sidebar .logo {
  padding: 2rem 1.5rem;
}
.sidebar .logo h2 { font-size: 1.8rem; }
.sidebar .logo span { background: linear-gradient(to right, var(--primary), var(--tertiary)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.sidebar nav {
  display: flex;
  flex-direction: column;
  padding: 0 1rem;
  gap: 0.5rem;
  flex-grow: 1;
}
.nav-btn {
  text-decoration: none;
  color: var(--text-muted);
  padding: 0.8rem 1rem;
  border-radius: 8px;
  transition: all var(--transition-speed);
  font-weight: 500;
}
.nav-btn:hover { background: var(--glass-hover); color: var(--text-main); }
.nav-btn.active {
  background: linear-gradient(to right, rgba(155, 81, 224, 0.2), transparent);
  color: var(--primary);
  border-left: 3px solid var(--primary);
}
.logout-btn { margin-top: auto; margin-bottom: 2rem; color: var(--danger); }
.logout-btn:hover { background: rgba(235, 87, 87, 0.1); color: var(--danger); }

/* Main Content Area */
.content-area {
  flex-grow: 1;
  margin-left: 250px;
  padding: 2rem 3rem;
  min-height: 100vh;
  background: radial-gradient(circle at top right, rgba(155, 81, 224, 0.05), transparent 50%),
              radial-gradient(circle at bottom left, rgba(86, 204, 242, 0.05), transparent 50%);
}

.view { display: none; }
.view.active { display: block; }
.page-header { margin-bottom: 2rem; padding-bottom: 1rem; border-bottom: 1px solid var(--glass-border); }

/* Dashboard */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; }
.stat-card { padding: 1.5rem; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.stat-card h3 { font-size: 1rem; color: var(--text-muted); margin-bottom: 0.5rem; font-weight: 500; }
.stat-card p { font-size: 2.5rem; font-weight: 600; background: linear-gradient(to right, var(--primary), var(--tertiary)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.latest-uploads { padding: 1.5rem; }
.latest-item {
  display: flex;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid var(--glass-border);
  transition: background var(--transition-speed);
}
.latest-item:last-child { border-bottom: none; }
.latest-item:hover { background: var(--glass-hover); border-radius: 8px; }
.latest-item .file-info { display: flex; flex-direction: column; }
.latest-item .file-name { font-weight: 500; }
.latest-item .file-project { font-size: 0.8rem; color: var(--tertiary); margin-top: 0.2rem; }
.latest-item .file-time { font-size: 0.8rem; color: var(--text-muted); }

/* Projects Grid */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.5rem; }
.project-card {
  padding: 2rem 1.5rem;
  text-align: center;
  cursor: pointer;
}
.project-card:hover { border-color: var(--primary); transform: translateY(-3px); box-shadow: 0 10px 30px rgba(155, 81, 224, 0.15); }
.project-icon { font-size: 3.5rem; margin-bottom: 1rem; display: inline-block; filter: drop-shadow(0 0 10px rgba(155, 81, 224, 0.3)); }
.project-name { font-weight: 500; font-size: 1.1rem; word-break: break-all; }

/* Media Manager Grid */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1.5rem; margin-top: 1.5rem; }
.media-card {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--border-radius);
  overflow: hidden;
  cursor: pointer;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--glass-border);
  transition: transform var(--transition-speed), border-color var(--transition-speed);
}
.media-card:hover {
  transform: scale(1.05);
  border-color: var(--primary);
  box-shadow: 0 8px 25px rgba(155, 81, 224, 0.2);
}
.media-card img, .media-card video { width: 100%; height: 100%; object-fit: cover; }
.media-card .no-preview { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 3rem; background: var(--glass-bg); }
.media-card .media-title {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(5px);
  color: #fff;
  font-size: 0.75rem;
  padding: 0.5rem;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Upload Progress */
.progress-panel { padding: 1rem; margin-bottom: 1.5rem; display: flex; flex-direction: column; gap: 0.5rem; }
.progress-header { font-size: 0.9rem; font-weight: 500; }
.progress-bar-bg { width: 100%; height: 6px; background: rgba(0,0,0,0.5); border-radius: 3px; overflow: hidden; }
.progress-bar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--primary), var(--tertiary)); transition: width 0.2s ease; }

/* Settings */
.settings-panel { max-width: 500px; padding: 2rem; }

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 100;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
}
.modal.show { display: flex; }
.modal-content {
  background: rgba(10, 10, 10, 0.6);
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  position: relative;
  display: flex;
  flex-direction: column;
}
.modal-body {
  display: flex;
  flex-direction: row;
  height: 100%;
  max-height: 80vh;
}
.modal-preview {
  flex: 1;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--glass-border);
  overflow: hidden;
  position: relative;
}
.modal-preview img, .modal-preview video { max-width: 100%; max-height: 100%; object-fit: contain; }
.modal-info {
  width: 320px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.modal-info h3 { margin-bottom: 1.5rem; border-bottom: 1px solid var(--glass-border); padding-bottom: 0.5rem; }
.info-list p { margin-bottom: 0.8rem; font-size: 0.9rem; color: var(--text-muted); }
.info-list strong { color: var(--text-main); }
.modal-actions { margin-top: auto; padding-top: 1.5rem; }
.close-modal {
  position: absolute;
  top: 10px;
  right: 15px;
  color: #fff;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  z-index: 101;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
.close-modal:hover { color: var(--danger); text-decoration: none; }
.file-icon-large { font-size: 6rem; opacity: 0.5; }

/* Responsive adjustments */
@media (max-width: 768px) {
  .app-container { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; align-items: center; padding: 0.5rem 1rem; border-right: none; border-bottom: 1px solid var(--glass-border); }
  .sidebar .logo { padding: 0.5rem; }
  .sidebar nav { flex-direction: row; overflow-x: auto; padding: 0; align-items: center; }
  .nav-btn.logout-btn { margin: 0 0 0 auto; }
  .content-area { margin-left: 0; padding: 1.5rem 1rem; }
  .modal-body { flex-direction: column; }
  .modal-preview { height: 40vh; border-right: none; border-bottom: 1px solid var(--glass-border); }
  .modal-info { width: 100%; }
}
