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

:root {
  /* Pastel & Modern Color Palette */
  --bg-color: #fcfcfb; /* Warm cream */
  --bg-surface: rgba(255, 255, 255, 0.7);
  --surface-solid: #ffffff;
  --primary-color: #1a8754; /* Emerald */
  --primary-hover: #146c43;
  --primary-olive: #2c5e1a; /* Dark Olive */
  --secondary-color: #f1f3f4; /* Warm gray */
  --secondary-hover: #e2e5e7;
  --text-main: #111111; /* Slate gray */
  --text-muted: #5f6368;
  --text-light: #adb5bd;
  --border-color: #e9ecef;
  --danger-color: #ffadad; /* Pastel red */
  
  /* Shadows & Borders */
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.02);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.05);
  --shadow-hover: 0 8px 32px rgba(0,0,0,0.05);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  
  /* Transitions */
  --transition: all 0.3s ease;
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
h1, h2, h3, h4, h5, h6 {
  font-family: 'Sora', sans-serif;
}

/* Utilities */
.hidden { display: none !important; }
.text-primary-emerald { color: var(--primary-color) !important; }
.bg-primary-emerald { background-color: var(--primary-color) !important; color: white; }
.pill-btn {
  border-radius: 9999px;
  color: var(--primary-color);
  background-color: rgba(26, 135, 84, 0.05);
  border: 1px solid rgba(26, 135, 84, 0.2);
  font-weight: 600;
  transition: var(--transition);
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  cursor: pointer;
}
.pill-btn:hover {
  background-color: rgba(26, 135, 84, 0.15);
  border-color: rgba(26, 135, 84, 0.3);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  outline: none;
  gap: 0.5rem;
}
.btn-primary {
  background-color: var(--primary-color);
  color: white;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}
.btn-secondary {
  background-color: var(--secondary-color);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover {
  background-color: var(--border-color);
  transform: translateY(-1px);
}
.btn-outline {
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background-color: var(--bg-color);
  border-color: var(--text-muted);
}
.btn-danger {
  background-color: var(--danger-color);
  color: white;
}
.btn-danger:hover {
  filter: brightness(0.95);
}

.input-field {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  transition: var(--transition);
  color: var(--text-main);
}
.input-field:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(163, 177, 138, 0.2);
}

/* Authentication Views */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 2rem;
}
.auth-card {
  background-color: var(--bg-surface);
  backdrop-filter: blur(12px);
  padding: 2.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 400px;
  text-align: center;
}
.auth-card h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}
.auth-card p {
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.auth-switch {
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.auth-switch a {
  color: var(--secondary-color);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

/* Dashboard Layout */
.dashboard {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background-color: var(--bg-surface);
  backdrop-filter: blur(12px);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  z-index: 10;
}
.brand {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.folder-list {
  flex: 1;
  overflow-y: auto;
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.folder-item {
  padding: 0.8rem 1rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-muted);
  font-weight: 500;
  transition: var(--transition);
  border-left: 3px solid transparent;
}
.folder-item:hover {
  background-color: var(--secondary-color);
  color: var(--text-main);
  border-left-color: var(--border-color);
}
.folder-item.active {
  background-color: var(--secondary-color);
  color: var(--text-main);
  font-weight: 600;
  border-left-color: var(--primary-emerald, var(--primary-color));
}
.folder-item.active svg {
  color: var(--primary-olive);
}
.sidebar-header {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1px;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.folder-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.folder-actions button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  padding: 0.2rem;
}
.folder-actions button:hover {
  color: var(--danger-color);
}
.user-menu {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}

/* Main Area */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-color);
  overflow-y: auto;
}
.topbar {
  padding: 1.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--bg-color);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar h2 {
  font-size: 1.5rem;
  font-weight: 600;
}
.page-header h1 {
  font-size: 2rem;
  color: var(--text-main);
  margin-bottom: 0.2rem;
  font-family: 'Sora', sans-serif;
  font-weight: 700;
}
.page-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}
#top-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(to right, var(--primary-color), var(--primary-olive));
  width: 0%;
  z-index: 1000;
  transition: width 0.3s ease, opacity 0.3s ease;
  opacity: 0;
}

/* Empty State & Upload Area */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
}
.upload-zone {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background-color: var(--bg-surface);
  backdrop-filter: blur(12px);
  margin: 2rem;
  min-height: 0; /* Prevents flex children from blowing out layout */
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--primary-color);
  background-color: rgba(26, 135, 84, 0.05);
}
.upload-zone input[type="file"] {
  display: none;
}
.upload-icon {
  font-size: 3rem;
  color: var(--primary-color);
  margin-bottom: 1rem;
}

/* Image Grid */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  padding: 0 2rem 2rem;
}
.image-card {
  background-color: var(--bg-surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}
.image-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}
.image-preview {
  height: 180px;
  background-color: #f1f3f5;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.image-preview img {
  width: 90%;
  height: 90%;
  object-fit: contain;
  border: 1px solid var(--primary-olive);
  border-radius: var(--radius-sm);
  background-color: white;
}
.image-delete {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(255,255,255,0.9);
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  color: var(--danger-color);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: var(--transition);
}
.image-card:hover .image-delete {
  opacity: 1;
}
.image-info {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}
.image-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.image-meta {
  display: flex;
  gap: 0.8rem;
  font-size: 0.75rem;
  color: var(--text-light);
  font-weight: 500;
}
.image-meta span {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}
.image-links {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.link-group {
  display: flex;
  gap: 0.5rem;
}
.link-input-group {
  display: flex;
  position: relative;
  flex: 1;
}
.link-input-group input {
  flex: 1;
  padding: 0.5rem 2.5rem 0.5rem 0.8rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--text-muted);
  background-color: var(--surface-solid);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.link-input-group button {
  position: absolute;
  right: 0.2rem;
  top: 0.2rem;
  bottom: 0.2rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 0.5rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.link-input-group button:hover {
  background-color: var(--secondary-color);
  color: var(--text-main);
}
.link-types {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.link-types button {
  flex: 1;
  font-size: 0.7rem;
  padding: 0.3rem;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0,0,0,0.4);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background-color: var(--bg-surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-hover);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.modal-title {
  font-size: 1.2rem;
  font-weight: 600;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
}
.modal-body {
  margin-bottom: 1.5rem;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background-color: var(--surface-color);
  color: var(--text-main);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: slideIn 0.3s ease forwards;
  border-left: 4px solid var(--primary-color);
}
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* Recent Activity */
.recent-activity {
  position: fixed;
  bottom: 80px;
  right: 20px;
  background-color: var(--bg-surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  box-shadow: var(--shadow-md);
  width: 250px;
  z-index: 90;
}
.recent-activity h4 {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.recent-activity .activity-item {
  font-size: 0.8rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.recent-activity .activity-item:last-child {
  margin-bottom: 0;
}


@media (max-width: 768px) {
  .dashboard {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
  }
  .folder-list {
    max-height: 150px;
  }
  .topbar {
    padding: 1rem;
  }
  .image-grid {
    padding: 0 1rem 1rem;
  }
}
