/* app/assets/stylesheets/application.css */

:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --bg-color: #f8fafc;
  --surface: rgba(255, 255, 255, 0.8);
  --surface-border: rgba(255, 255, 255, 0.4);
  --text-main: #0f172a;
  --text-muted: #64748b;
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 2rem;
  --border-radius: 12px;
}

body {
  margin: 0;
  font-family: var(--font-family);
  background-color: var(--bg-color);
  background-image: 
    radial-gradient(at 40% 20%, hsla(253,16%,7%,0.03) 0px, transparent 50%),
    radial-gradient(at 80% 0%, hsla(189,100%,56%,0.03) 0px, transparent 50%),
    radial-gradient(at 0% 50%, hsla(355,100%,93%,0.03) 0px, transparent 50%);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
}

/* Sidebar styling via glassmorphism */
.sidebar {
  width: 250px;
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid var(--surface-border);
  padding: var(--spacing-lg) var(--spacing-md);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  box-sizing: border-box;
}

.sidebar-logo {
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--primary);
  margin-bottom: var(--spacing-lg);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  flex-grow: 1;
}

.nav-link {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  padding: 10px 16px;
  border-radius: 8px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-link:hover, .nav-link.active {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
  transform: translateX(4px);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Main Content */
.main-content {
  flex-grow: 1;
  padding: var(--spacing-lg) 40px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

body.auth-page {
  display: block; /* Disable row flex on body to avoid pushing to the left */
}

body.auth-page .main-content {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 0;
  max-width: none;
}

/* Typography */
h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-top: 0;
  margin-bottom: var(--spacing-lg);
  color: var(--text-main);
}

h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: var(--spacing-md);
}

/* Cards */
.card {
  background: var(--surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--surface-border);
  border-radius: var(--border-radius);
  padding: var(--spacing-lg);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-family: var(--font-family);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  font-size: 0.95rem;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 8px -1px rgba(99, 102, 241, 0.5);
}

.btn-outline {
  background: transparent;
  color: var(--text-main);
  border: 1px solid #cbd5e1;
}

.btn-outline:hover {
  background: #f1f5f9;
}

/* Tables */
.table-wrapper {
  background: var(--surface);
  backdrop-filter: blur(12px);
  border-radius: var(--border-radius);
  border: 1px solid var(--surface-border);
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 16px;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}

th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
}

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

tr:hover td {
  background: #f1f5f9;
}

/* Forms */
.form-group {
  margin-bottom: var(--spacing-md);
}

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

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: white;
  font-family: var(--font-family);
  font-size: 1rem;
  color: var(--text-main);
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Flash Messages */
.flash {
  padding: 12px 20px;
  border-radius: 8px;
  margin-bottom: var(--spacing-lg);
  font-weight: 500;
  animation: slideIn 0.3s ease-out;
}

.flash-notice {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.flash-alert {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

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

/* Mobile Header & Drawer */
.mobile-header { display: none; }
.sidebar-overlay { display: none; }

/* Responsive */
@media (max-width: 768px) {
  body {
    flex-direction: column;
  }
  
  .mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--surface-border);
    position: sticky;
    top: 0;
    z-index: 900;
  }
  
  .hamburger-btn {
    background: none; border: none;
    color: var(--text-main);
    cursor: pointer; padding: 4px;
    display: flex; align-items: center; justify-content: center;
  }
  
  .mobile-logo {
    font-weight: 800; font-size: 1.25rem;
    color: var(--primary); text-decoration: none;
    display: flex; align-items: center; gap: 6px;
  }

  .sidebar-overlay.open {
    display: block; position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.3);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 998;
    animation: fadeIn 0.3s ease-out;
  }

  /* Slide-out Sidebar constraints */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px; height: 100vh;
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0,0,0,0.1);
    background: rgba(255, 255, 255, 0.95);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }

  .main-content { 
    padding: var(--spacing-md); 
  }
}

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