:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-glass: rgba(255, 255, 255, 0.03);
  --bg-glass-hover: rgba(255, 255, 255, 0.08);
  
  --accent-primary: #8a2be2;
  --accent-secondary: #4169e1;
  --accent-glow: rgba(138, 43, 226, 0.4);
  
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  
  --border-color: rgba(255, 255, 255, 0.1);
  --border-glow: rgba(138, 43, 226, 0.3);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 24px;
  
  --shadow-glow: 0 0 20px var(--accent-glow);
  --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 15% 50%, rgba(138, 43, 226, 0.08), transparent 25%),
    radial-gradient(circle at 85% 30%, rgba(65, 105, 225, 0.08), transparent 25%);
}

h1, h2, h3, h4, h5, h6 { font-weight: 700; line-height: 1.2; }
h1 { font-size: 3.5rem; margin-bottom: 1rem; }
h2 { font-size: 2.5rem; margin-bottom: 1rem; }
h3 { font-size: 1.75rem; margin-bottom: 0.75rem; }

.gradient-text {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

p { color: var(--text-secondary); margin-bottom: 1rem; }

.container { max-width: 1400px; margin: 0 auto; padding: 0 2rem; }

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: white;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.glass-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-glass);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.75rem 1.5rem; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 1rem; cursor: pointer;
  transition: all var(--transition-normal); text-decoration: none;
  border: none; outline: none; gap: 0.5rem;
}

.btn-sm { padding: 0.5rem 1rem; font-size: 0.875rem; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: white;
  box-shadow: 0 4px 15px rgba(138, 43, 226, 0.2);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(138, 43, 226, 0.4);
  filter: brightness(1.1);
}

.btn-outline { background: transparent; color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-outline:hover { background: var(--bg-glass-hover); border-color: rgba(255, 255, 255, 0.2); }

.btn-success { background: #4CAF50; color: white; }
.btn-success:hover { background: #45a049; transform: translateY(-2px); }

.btn-danger { background: #f44336; color: white; }
.btn-danger:hover { background: #da190b; transform: translateY(-2px); }

.app-container {
  display: grid; grid-template-columns: 350px 1fr; gap: 2rem;
  padding: 2rem 0; height: calc(100vh - 100px);
}

.form-group { margin-bottom: 1.5rem; }
.form-label { display: block; font-weight: 500; margin-bottom: 0.5rem; color: var(--text-primary); }
.form-control {
  width: 100%; background: rgba(0, 0, 0, 0.2); border: 1px solid var(--border-color);
  color: var(--text-primary); padding: 0.75rem 1rem; border-radius: var(--radius-sm);
  font-size: 1rem; transition: all var(--transition-fast);
}

.form-control:focus { outline: none; border-color: var(--accent-primary); box-shadow: 0 0 0 2px rgba(138, 43, 226, 0.2); }
textarea.form-control { min-height: 120px; resize: vertical; }

.form-control option { background-color: var(--bg-secondary); color: white; }

/* SOP Viewer & Editor */
.sop-viewer-container {
  display: flex; flex-direction: column; background: #ffffff;
  border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-glass);
}

.sop-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem; background: #f8f9fa; border-bottom: 1px solid #e0e0e0; color: #333;
}

.sop-actions { display: flex; gap: 0.5rem; }

.sop-content-area {
  flex: 1; padding: 2rem; overflow-y: auto; color: #1a1a1a;
  position: relative; background: #fff;
}

.ql-toolbar.ql-snow { border: none !important; border-bottom: 1px solid #e0e0e0 !important; background: #f1f3f5; }
.ql-container.ql-snow { border: none !important; font-family: 'Inter', sans-serif; font-size: 1rem; }
.ql-editor { min-height: 500px; }
.ql-editor h1 { font-size: 2rem; border-bottom: 2px solid var(--accent-primary); padding-bottom: 0.5rem; margin-bottom: 1.5rem; }
.ql-editor h2 { font-size: 1.5rem; margin-top: 1.5rem; margin-bottom: 0.75rem; color: #333; }
.ql-editor h3 { font-size: 1.2rem; margin-top: 1rem; color: #444; }
.ql-editor p, .ql-editor ul, .ql-editor ol { margin-bottom: 1rem; line-height: 1.7; }
.ql-editor strong { color: #000; }

.loader { display: none; flex-direction: column; align-items: center; justify-content: center; height: 100%; }
.spinner {
  width: 50px; height: 50px; border: 3px solid rgba(138, 43, 226, 0.3);
  border-radius: 50%; border-top-color: var(--accent-primary);
  animation: spin 1s ease-in-out infinite; margin-bottom: 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.generating-text { font-weight: 500; color: var(--accent-primary); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.fade-in { animation: fadeIn 0.5s ease-out forwards; }
.slide-up { animation: slideUp 0.5s ease-out forwards; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* Dashboard Styles */
.dashboard-header {
  display: flex; justify-content: space-between; align-items: center; margin: 2rem 0;
}

.department-selector {
  display: flex; align-items: center; gap: 1rem; background: var(--bg-glass);
  padding: 1rem; border-radius: var(--radius-md); border: 1px solid var(--border-color);
}

.sop-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.5rem;
}

.sop-card {
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 1.5rem;
  transition: transform var(--transition-normal), border-color var(--transition-normal);
  display: flex; flex-direction: column; height: 100%;
}

.sop-card:hover {
  transform: translateY(-5px); border-color: var(--accent-primary); box-shadow: var(--shadow-glow);
}

.sop-card-header {
  display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem;
}

.sop-badge {
  background: rgba(138, 43, 226, 0.2); color: #d8b4fe; padding: 0.25rem 0.5rem;
  border-radius: 4px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
}

.sop-card h3 { font-size: 1.25rem; margin-bottom: 0.5rem; }
.sop-card p { font-size: 0.9rem; color: var(--text-muted); flex-grow: 1; }
.sop-card-footer {
  display: flex; justify-content: space-between; align-items: center; margin-top: 1.5rem;
  padding-top: 1rem; border-top: 1px solid var(--border-color);
}

.date-text { font-size: 0.8rem; color: var(--text-muted); }
