/* ============================================================
   Amma's Art Studio - Stylesheet
   Modern Dark Theme with Glassmorphism
   ============================================================ */

/* CSS Variables */
:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-sidebar: #020617;
  --accent: #38bdf8;
  --accent-hover: #0ea5e9;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #22c55e;
  --warning: #facc15;
  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  --text-muted: #cbd5e1;
  --border: rgba(255, 255, 255, 0.1);
  --glass-bg: rgba(30, 41, 59, 0.6);
  --glass-border: rgba(255, 255, 255, 0.15);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Utility Classes */
.hidden {
  display: none !important;
}

.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
}

/* ==================== LOGIN PAGE ==================== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 20%, #1e3a5f 0%, #0f172a 50%, #020617 100%);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 45px 35px;
  border-radius: 24px;
  text-align: center;
  animation: fadeInUp 0.6s ease-out;
}

.login-icon {
  font-size: 56px;
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
}

.login-card h1 {
  font-size: 32px;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-card > p {
  color: var(--text-secondary);
  margin-bottom: 30px;
  font-size: 15px;
}

.input-group {
  margin-bottom: 16px;
}

.input-group input,
.input-group textarea,
.input-group select,
.category-create input,
.category-row input {
  width: 100%;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  outline: none;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  font-size: 15px;
  transition: all 0.3s ease;
}

.input-group input:focus,
.input-group textarea:focus,
.input-group select:focus,
.category-create input:focus,
.category-row input:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.input-group input::placeholder,
.input-group textarea::placeholder,
.category-create input::placeholder,
.category-row input::placeholder {
  color: var(--text-secondary);
}

.input-group select {
  appearance: none;
}

.input-group label {
  display: block;
  text-align: left;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
}

.input-group textarea {
  resize: vertical;
  min-height: 80px;
}

.file-hint {
  display: block;
  text-align: left;
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 12px;
}

/* Buttons */
button {
  border: none;
  padding: 14px 22px;
  border-radius: 14px;
  cursor: pointer;
  background: var(--accent);
  color: var(--bg-sidebar);
  font-weight: 700;
  font-size: 15px;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(56, 189, 248, 0.3);
}

button:active {
  transform: translateY(0);
}

.login-card button {
  width: 100%;
  margin-top: 10px;
}

small, #uploadMessage, #loginMessage, #categoryMessage, #backupMessage {
  display: block;
  margin-top: 16px;
  color: var(--warning);
  font-size: 14px;
  min-height: 20px;
}

#uploadMessage.success,
#loginMessage.success,
#categoryMessage.success,
#backupMessage.success {
  color: var(--success);
}

/* Button loader */
.btn-loader {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--text-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ==================== APP LAYOUT ==================== */
.app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
}

.sidebar-header h2 {
  margin-bottom: 35px;
  font-size: 22px;
  text-align: center;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar nav {
  flex: 1;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-bottom: 10px;
  text-align: left;
  background: transparent;
  color: var(--text-muted);
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 500;
}

.nav-btn:hover {
  background: rgba(56, 189, 248, 0.1);
  color: var(--accent);
  transform: none;
  box-shadow: none;
}

.nav-btn.active {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent);
}

.logout {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  width: 100%;
  margin-top: auto;
}

.logout:hover {
  background: var(--danger);
  color: white;
  box-shadow: 0 8px 20px rgba(239, 68, 68, 0.3);
}

/* Content Area */
.content {
  flex: 1;
  margin-left: 260px;
  padding: 30px 35px;
  min-height: 100vh;
}

.topbar {
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  font-size: 28px;
  margin-bottom: 4px;
}

.topbar p {
  color: var(--text-secondary);
  font-size: 14px;
}

/* ==================== DASHBOARD ==================== */
.welcome-banner {
  padding: 30px;
  border-radius: 20px;
  margin-bottom: 25px;
  animation: fadeInUp 0.5s ease-out;
}

.welcome-banner h2 {
  font-size: 26px;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-banner p {
  color: var(--text-secondary);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 35px;
}

.stat-card {
  padding: 28px;
  border-radius: 20px;
  text-align: center;
  transition: transform 0.3s ease;
  animation: fadeInUp 0.6s ease-out;
}

.stat-card:hover {
  transform: translateY(-5px);
}

.stat-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.stat-card h3 {
  color: var(--text-secondary);
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 500;
}

.stat-card h2 {
  font-size: 42px;
  background: linear-gradient(135deg, var(--accent), #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.recent-section h3 {
  margin-bottom: 18px;
  font-size: 20px;
  color: var(--text-muted);
}

.recent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.recent-item {
  border-radius: 16px;
  overflow: hidden;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  transition: transform 0.3s ease;
}

.recent-item:hover {
  transform: scale(1.03);
}

.recent-item img,
.recent-item video,
.recent-item .file-preview {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
}

.recent-item p {
  padding: 10px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==================== UPLOAD ==================== */
.upload-card {
  max-width: 540px;
  padding: 35px;
  border-radius: 20px;
  animation: fadeInUp 0.5s ease-out;
}

.upload-card h2 {
  margin-bottom: 8px;
  font-size: 24px;
}

.upload-card > p {
  color: var(--text-secondary);
  margin-bottom: 25px;
}

.inline-control {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.inline-control button {
  white-space: nowrap;
}

/* ==================== GALLERY ==================== */
.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
}

.gallery-header h2 {
  font-size: 24px;
}

.category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 24px;
}

.category-chip {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 14px;
}

.category-chip.active {
  background: var(--accent);
  color: var(--bg-sidebar);
  border-color: var(--accent);
}

.refresh-btn {
  background: var(--bg-secondary);
  color: var(--text-muted);
  padding: 10px 18px;
  font-size: 14px;
}

.refresh-btn:hover {
  background: var(--accent);
  color: var(--bg-sidebar);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.gallery-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  animation: fadeInUp 0.5s ease-out;
}

.gallery-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.gallery-card img,
.gallery-card video,
.gallery-card .file-preview {
  width: 100%;
  height: 220px;
  object-fit: cover;
  background: var(--bg-sidebar);
  display: block;
}

.file-preview {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px;
  text-align: center;
}

.file-preview .file-icon {
  font-size: 42px;
}

.file-preview strong {
  width: 100%;
  color: var(--text-primary);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-preview span {
  color: var(--text-secondary);
  font-size: 12px;
}

.file-preview a,
.download-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.gallery-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.gallery-actions .download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 39px;
  border-radius: 14px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  font-size: 13px;
}

.gallery-info {
  padding: 18px;
}

.gallery-info h4 {
  font-size: 17px;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.gallery-info p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.gallery-info .date {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: block;
}

.category-badge {
  display: inline-flex;
  width: fit-content;
  margin-bottom: 10px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.gallery-info button {
  background: var(--danger);
  color: white;
  padding: 10px 16px;
  font-size: 13px;
  width: 100%;
}

.gallery-info button:hover {
  background: var(--danger-hover);
  box-shadow: 0 8px 20px rgba(239, 68, 68, 0.3);
}

.loading-text {
  color: var(--text-secondary);
  text-align: center;
  padding: 40px;
  grid-column: 1 / -1;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
  grid-column: 1 / -1;
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

/* ==================== CATEGORY MANAGER ==================== */
.category-manager,
.backup-manager {
  max-width: 760px;
  padding: 35px;
  border-radius: 20px;
  animation: fadeInUp 0.5s ease-out;
}

.category-manager h2,
.backup-manager h2 {
  font-size: 24px;
  margin-bottom: 8px;
}

.category-manager > p,
.backup-manager p {
  color: var(--text-secondary);
  margin-bottom: 22px;
}

.category-create {
  margin-bottom: 12px;
}

.category-list {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.category-row,
.backup-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
}

.backup-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.backup-list {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

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

.category-meta {
  color: var(--text-secondary);
  font-size: 13px;
}

.category-row .delete-category-btn {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.category-row .delete-category-btn:hover {
  background: var(--danger);
  color: white;
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  .app {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 15px;
    gap: 10px;
  }

  .sidebar-header {
    width: 100%;
    text-align: center;
  }

  .sidebar-header h2 {
    margin-bottom: 15px;
  }

  .sidebar nav {
    display: flex;
    flex: 1;
    gap: 8px;
  }

  .nav-btn {
    flex: 1;
    justify-content: center;
    margin-bottom: 0;
    padding: 10px;
    font-size: 13px;
  }

  .logout {
    width: auto;
    margin-top: 0;
    padding: 10px 16px;
  }

  .content {
    margin-left: 0;
    padding: 20px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
  }

  .inline-control,
  .category-row,
  .backup-row,
  .backup-header,
  .gallery-actions {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .topbar h1 {
    font-size: 22px;
  }
}

@media (max-width: 480px) {
  .login-card {
    padding: 30px 20px;
  }

  .login-card h1 {
    font-size: 26px;
  }

  .gallery-grid {
    grid-template-columns: 1fr;
  }

  .recent-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

