/* shadcn/ui Design System for S3 Manager */
/* Based on https://ui.shadcn.com - Tailwind CSS custom properties approach */

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

:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 240 10% 3.9%;
  --primary: 240 5.9% 10%;
  --primary-foreground: 0 0% 98%;
  --secondary: 240 4.8% 95.9%;
  --secondary-foreground: 240 5.9% 10%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --accent: 240 4.8% 95.9%;
  --accent-foreground: 240 5.9% 10%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 240 5.9% 10%;
  --radius: 0.5rem;
}

.dark {
  --background: 240 10% 3.9%;
  --foreground: 0 0% 98%;
  --card: 240 10% 3.9%;
  --card-foreground: 0 0% 98%;
  --popover: 240 10% 3.9%;
  --popover-foreground: 0 0% 98%;
  --primary: 0 0% 98%;
  --primary-foreground: 240 5.9% 10%;
  --secondary: 240 3.7% 15.9%;
  --secondary-foreground: 0 0% 98%;
  --muted: 240 3.7% 15.9%;
  --muted-foreground: 240 5% 64.9%;
  --accent: 240 3.7% 15.9%;
  --accent-foreground: 0 0% 98%;
  --destructive: 0 62.8% 30.6%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 3.7% 15.9%;
  --input: 240 3.7% 15.9%;
  --ring: 240 4.9% 83.9%;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  border-color: hsl(var(--border));
}

html {
  font-size: 16px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   LAYOUT COMPONENTS
   ============================================ */

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-content {
  flex: 1;
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* ============================================
   NAVBAR / HEADER
   ============================================ */

.navbar {
  background-color: hsl(var(--background));
  border-bottom: 1px solid hsl(var(--border));
  padding: 0 1.5rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
  background-color: hsl(var(--background) / 0.8);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: hsl(var(--foreground));
  font-weight: 600;
  font-size: 1.25rem;
}

.navbar-brand svg {
  width: 28px;
  height: 28px;
  color: hsl(var(--primary));
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ============================================
   BREADCRUMB
   ============================================ */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0;
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  flex-wrap: wrap;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.breadcrumb-item a {
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  transition: color 0.15s ease;
}

.breadcrumb-item a:hover {
  color: hsl(var(--foreground));
}

.breadcrumb-separator {
  color: hsl(var(--muted-foreground));
}

.breadcrumb-current {
  color: hsl(var(--foreground));
  font-weight: 500;
}

/* ============================================
   CARDS
   ============================================ */

.card {
  background-color: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  overflow: hidden;
  transition: all 0.2s ease;
}

.card-hover:hover {
  border-color: hsl(var(--ring));
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  transform: translateY(-2px);
}

.card-header {
  padding: 1.5rem 1.5rem 0;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  line-height: 1.25;
}

.card-description {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.25rem;
}

.card-content {
  padding: 1.5rem;
}

.card-footer {
  padding: 1rem 1.5rem;
  background-color: hsl(var(--muted) / 0.3);
  border-top: 1px solid hsl(var(--border));
}

/* Bucket Card Specific */
.bucket-card {
  display: block;
  text-decoration: none;
  color: inherit;
}

.bucket-card-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
}

.bucket-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.bucket-icon svg {
  width: 24px;
  height: 24px;
}

.bucket-info {
  flex: 1;
  min-width: 0;
}

.bucket-name {
  font-weight: 600;
  font-size: 1rem;
  color: hsl(var(--foreground));
  margin-bottom: 0.25rem;
}

.bucket-meta {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  height: 40px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  font-family: inherit;
}

.btn:disabled {
  pointer-events: none;
  opacity: 0.5;
}

.btn-primary {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.btn-primary:hover {
  background-color: hsl(var(--primary) / 0.9);
}

.btn-secondary {
  background-color: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}

.btn-secondary:hover {
  background-color: hsl(var(--secondary) / 0.8);
}

.btn-outline {
  background-color: transparent;
  border-color: hsl(var(--border));
  color: hsl(var(--foreground));
}

.btn-outline:hover {
  background-color: hsl(var(--accent));
  border-color: hsl(var(--accent));
}

.btn-ghost {
  background-color: transparent;
  color: hsl(var(--foreground));
}

.btn-ghost:hover {
  background-color: hsl(var(--accent));
}

.btn-destructive {
  background-color: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}

.btn-destructive:hover {
  background-color: hsl(var(--destructive) / 0.9);
}

.btn-icon {
  width: 40px;
  padding: 0;
}

.btn-sm {
  height: 32px;
  padding: 0.25rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-lg {
  height: 48px;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

/* Floating Action Button */
.fab-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 40;
}

.fab {
  width: 56px;
  height: 56px;
  border-radius: 9999px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.fab:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  transform: scale(1.05);
}

/* ============================================
   INPUTS
   ============================================ */

.input {
  display: flex;
  height: 40px;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--input));
  background-color: hsl(var(--background));
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: hsl(var(--foreground));
  transition: all 0.15s ease;
}

.input::placeholder {
  color: hsl(var(--muted-foreground));
}

.input:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.1);
}

.input:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.input-error {
  border-color: hsl(var(--destructive));
}

.input-error:focus {
  box-shadow: 0 0 0 3px hsl(var(--destructive) / 0.1);
}

.label {
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--foreground));
  margin-bottom: 0.5rem;
  display: block;
}

.form-group {
  margin-bottom: 1rem;
}

.form-hint {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.25rem;
}

.form-error {
  font-size: 0.75rem;
  color: hsl(var(--destructive));
  margin-top: 0.25rem;
}

/* ============================================
   TABLES
   ============================================ */

.table-container {
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  overflow: visible;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table thead {
  background-color: hsl(var(--muted) / 0.5);
}

.table thead tr:first-child th:first-child {
  border-top-left-radius: var(--radius);
}

.table thead tr:first-child th:last-child {
  border-top-right-radius: var(--radius);
}

.table tbody tr:last-child td:first-child {
  border-bottom-left-radius: var(--radius);
}

.table tbody tr:last-child td:last-child {
  border-bottom-right-radius: var(--radius);
}

.table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  border-bottom: 1px solid hsl(var(--border));
}

.table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background-color: hsl(var(--muted) / 0.3);
}

.table-row-clickable {
  cursor: pointer;
}

.table-row-clickable:hover {
  background-color: hsl(var(--accent)) !important;
}

/* ============================================
   MODALS / DIALOGS
   ============================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

.modal-overlay.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background-color: hsl(var(--background));
  border-radius: var(--radius);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  max-width: 500px;
  width: 90%;
  max-height: 85vh;
  overflow: auto;
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from { 
    opacity: 0;
    transform: translateY(10px);
  }
  to { 
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  padding: 1.5rem 1.5rem 0;
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.modal-description {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.5rem;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  border-top: 1px solid hsl(var(--border));
}

/* ============================================
   DROPDOWN MENU
   ============================================ */

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.25rem;
  min-width: 160px;
  background-color: hsl(var(--popover));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  z-index: 50;
  display: none;
  animation: slideDown 0.1s ease;
  padding: 0.25rem;
}

.dropdown-menu.active {
  display: block;
}

.dropdown-menu.dropdown-menu-up {
  top: auto;
  bottom: 100%;
  margin-top: 0;
  margin-bottom: 0.25rem;
  animation: slideUp 0.1s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideDown {
  from { 
    opacity: 0;
    transform: translateY(-4px);
  }
  to { 
    opacity: 1;
    transform: translateY(0);
  }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  transition: background-color 0.1s ease;
  text-decoration: none;
}

.dropdown-item:hover {
  background-color: hsl(var(--accent));
}

.dropdown-item-destructive {
  color: hsl(var(--destructive));
}

.dropdown-item-destructive:hover {
  background-color: hsl(var(--destructive) / 0.1);
}

.dropdown-separator {
  height: 1px;
  background-color: hsl(var(--border));
  margin: 0.25rem 0;
}

/* ============================================
   ALERTS
   ============================================ */

.alert {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid;
}

.alert-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.alert-content {
  flex: 1;
}

.alert-title {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
}

.alert-description {
  font-size: 0.875rem;
  opacity: 0.9;
}

.alert-error {
  background-color: hsl(var(--destructive) / 0.1);
  border-color: hsl(var(--destructive) / 0.3);
  color: hsl(var(--destructive));
}

.alert-success {
  background-color: hsl(142 76% 36% / 0.1);
  border-color: hsl(142 76% 36% / 0.3);
  color: hsl(142 76% 36%);
}

.alert-warning {
  background-color: hsl(48 96% 53% / 0.1);
  border-color: hsl(48 96% 53% / 0.3);
  color: hsl(45 93% 30%);
}

.alert-info {
  background-color: hsl(221 83% 53% / 0.1);
  border-color: hsl(221 83% 53% / 0.3);
  color: hsl(221 83% 53%);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  background-color: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  min-width: 300px;
  max-width: 400px;
  animation: slideInRight 0.2s ease;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toast-title {
  font-weight: 600;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
}

.toast-description {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.25rem;
}

.toast-progress {
  height: 4px;
  background-color: hsl(var(--muted));
  border-radius: 9999px;
  margin-top: 0.75rem;
  overflow: hidden;
}

.toast-progress-bar {
  height: 100%;
  background-color: hsl(var(--primary));
  width: 0%;
  transition: width 0.3s ease;
}

/* ============================================
   BADGE
   ============================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 9999px;
}

.badge-default {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.badge-secondary {
  background-color: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}

.badge-outline {
  background-color: transparent;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
}

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  color: hsl(var(--muted-foreground));
  margin-bottom: 1rem;
}

.empty-state-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  margin-bottom: 0.5rem;
}

.empty-state-description {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  max-width: 400px;
  margin-bottom: 1.5rem;
}

/* ============================================
   S3 INSTANCE SWITCHER
   ============================================ */

.instance-switcher {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  z-index: 40;
}

.instance-btn {
  width: 48px;
  height: 48px;
  border-radius: 9999px;
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.15s ease;
}

.instance-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.instance-dropdown {
  position: absolute;
  bottom: 56px;
  left: 0;
  min-width: 220px;
  background-color: hsl(var(--popover));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  display: none;
  padding: 0.25rem;
}

.instance-dropdown.active {
  display: block;
  animation: slideUp 0.15s ease;
}

.instance-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  transition: background-color 0.1s ease;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
}

.instance-item:hover {
  background-color: hsl(var(--accent));
}

.instance-item.active {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.instance-item-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  background-color: hsl(var(--muted));
  display: flex;
  align-items: center;
  justify-content: center;
}

.instance-item.active .instance-item-icon {
  background-color: hsl(var(--primary-foreground) / 0.2);
}

/* ============================================
   FILE/OBJECT ICON
   ============================================ */

.file-icon {
  width: 20px;
  height: 20px;
  color: hsl(var(--muted-foreground));
}

.folder-icon {
  color: hsl(48 96% 53%);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.text-center { text-align: center; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: hsl(var(--muted-foreground)); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.ml-auto { margin-left: auto; }
.w-full { width: 100%; }
.hidden { display: none; }
.truncate { 
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Grid Layout */
.grid {
  display: grid;
}

.grid-cols-1 {
  grid-template-columns: repeat(1, minmax(0, 1fr));
}

@media (min-width: 640px) {
  .sm\:grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .lg\:grid-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ============================================
   SKELETON LOADING
   ============================================ */

.skeleton {
  background: linear-gradient(
    90deg,
    hsl(var(--muted)) 25%,
    hsl(var(--muted) / 0.5) 50%,
    hsl(var(--muted)) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  .main-content {
    padding: 1rem;
  }
  
  .navbar {
    padding: 0 1rem;
  }
  
  .table-container {
    overflow-x: auto;
  }
  
  .fab-container {
    bottom: 1rem;
    right: 1rem;
  }
  
  .fab {
    width: 48px;
    height: 48px;
  }
  
  .instance-switcher {
    bottom: 1rem;
    left: 1rem;
  }
}
