/* ===== CorsZero Vault — Minimalist Industrial Theme ===== */

:root {
  /* Core Colors */
  --bg-primary: #f8f9fa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f3f4f6;
  
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  
  /* Accents */
  --accent-blue: #2563eb;
  --accent-blue-hover: #1d4ed8;
  --accent-blue-light: #eff6ff;
  
  --accent-red: #dc2626;
  --accent-red-hover: #b91c1c;
  --accent-red-light: #fef2f2;
  
  --accent-green: #059669;
  --accent-green-light: #ecfdf5;

  /* UI Elements */
  --border-color: #e5e7eb;
  --border-focus: #2563eb;
  
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  /* Shadows (Subtle only) */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);

  /* Typography */
  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --transition-fast: 0.1s ease;
  --transition-normal: 0.2s ease;
}

[data-theme="dark"] {
  /* Core Colors */
  --bg-primary: #000000;
  --bg-secondary: #0a0a0a;
  --bg-tertiary: #141414;
  
  --text-primary: #fafafa;
  --text-secondary: #a3a3a3;
  --text-muted: #525252;
  
  /* Accents */
  --accent-blue: #3b82f6;
  --accent-blue-hover: #60a5fa;
  --accent-blue-light: rgba(59, 130, 246, 0.15);
  
  --accent-red: #ef4444;
  --accent-red-hover: #f87171;
  --accent-red-light: rgba(239, 68, 68, 0.15);
  
  --accent-green: #10b981;
  --accent-green-light: rgba(16, 185, 129, 0.15);

  /* UI Elements */
  --border-color: #262626;
  --border-focus: #3b82f6;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
input, button, select, textarea { font-family: inherit; }

.hidden { display: none !important; }
.screen { display: none; }
.screen.active { display: block; }

/* ===== Minimalist Card ===== */
.glass-card { /* Kept class name for JS compatibility but removed glass effect */
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

/* ===== Buttons (Flat & Utilitarian) ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px;
  font-size: 0.875rem; font-weight: 500;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer; transition: all var(--transition-fast);
  white-space: nowrap; position: relative;
  background: var(--bg-secondary); color: var(--text-primary);
  border-color: var(--border-color);
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--bg-tertiary); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
  background: var(--accent-blue);
  color: #fff;
  border-color: var(--accent-blue);
}
.btn-primary:hover { background: var(--accent-blue-hover); border-color: var(--accent-blue-hover); color: #fff; }

.btn-ghost {
  background: transparent; border-color: transparent; box-shadow: none;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.btn-danger {
  background: var(--bg-secondary); color: var(--accent-red);
  border-color: var(--border-color);
}
.btn-danger:hover { background: var(--accent-red-light); border-color: rgba(220, 38, 38, 0.3); }

.btn-icon {
  padding: 6px; width: 32px; height: 32px;
}

.btn-accent {
  background: var(--accent-blue-light); color: var(--accent-blue);
  border-color: rgba(37, 99, 235, 0.2); box-shadow: none;
}
.btn-accent:hover { background: rgba(37, 99, 235, 0.15); }

.btn-sm { padding: 6px 12px; font-size: 0.8125rem; }
.btn-full { width: 100%; }

.btn-loader {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Forms (Sharp & Crisp) ===== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 0.8125rem; font-weight: 600;
  color: var(--text-primary); margin-bottom: 6px;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 12px;
  background: var(--bg-secondary); color: var(--text-primary);
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  font-size: 0.875rem; transition: border-color var(--transition-fast);
  outline: none; box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.form-group input::placeholder, .form-group textarea::placeholder { color: var(--text-muted); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-hint { display: block; font-size: 0.75rem; color: var(--text-secondary); margin-top: 4px; }

.password-input-wrapper { position: relative; }
.password-input-wrapper input { padding-right: 40px; font-family: var(--font-mono); letter-spacing: 1px; }
.password-input-wrapper input::placeholder { font-family: var(--font-sans); letter-spacing: normal; }
.toggle-password {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 4px; width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
}
.toggle-password:hover { color: var(--text-primary); background: var(--bg-tertiary); border-radius: var(--radius-sm); }
.toggle-password svg { width: 16px; height: 16px; }

/* ===== Auth Screen ===== */
.auth-wrapper {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 40px 20px;
}

.auth-brand { text-align: center; margin-bottom: 32px; }
.brand-icon { display: inline-block; margin-bottom: 12px; }
.brand-icon svg { width: 48px; height: 48px; color: var(--text-primary); }
.brand-title { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.brand-subtitle { font-size: 0.875rem; color: var(--text-secondary); margin-top: 4px; }

.auth-card { width: 100%; max-width: 400px; padding: 32px; background: var(--bg-secondary); }

.auth-tabs { display: flex; border-bottom: 1px solid var(--border-color); margin-bottom: 24px; }
.auth-tab {
  flex: 1; padding: 12px; font-size: 0.875rem; font-weight: 500;
  background: transparent; border: none; color: var(--text-secondary);
  cursor: pointer; position: relative;
}
.auth-tab::after {
  content: ''; position: absolute; bottom: -1px; left: 0; right: 0;
  height: 2px; background: transparent; transition: background var(--transition-fast);
}
.auth-tab.active { color: var(--text-primary); font-weight: 600; }
.auth-tab.active::after { background: var(--text-primary); }
.auth-tab:not(.active):hover { color: var(--text-primary); background: var(--bg-tertiary); }

/* ===== Top Nav ===== */
.top-nav {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; height: 56px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.nav-brand { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.nav-icon svg { width: 24px; height: 24px; color: var(--text-primary); }
.nav-title { font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; }

.nav-actions { display: flex; align-items: center; gap: 16px; }
.nav-user { display: flex; align-items: center; gap: 8px; }
.user-avatar {
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  background: var(--bg-tertiary); border: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 600; color: var(--text-primary);
}
.user-name { font-size: 0.875rem; font-weight: 500; color: var(--text-secondary); }

/* ===== Main Layout ===== */
.main-content {
  display: flex; min-height: calc(100vh - 56px);
}

/* ===== Sidebar ===== */
.sidebar {
  width: 260px; min-width: 260px;
  border-right: 1px solid var(--border-color);
  background: var(--bg-primary);
  display: flex; flex-direction: column;
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--border-color);
}
.sidebar-header h2 { font-size: 0.75rem; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }

.org-list { flex: 1; overflow-y: auto; padding: 12px 8px; }

.org-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; margin-bottom: 4px;
  border-radius: var(--radius-sm); cursor: pointer;
  transition: background var(--transition-fast);
}
.org-item:hover { background: var(--bg-secondary); border: 1px solid var(--border-color); margin: -1px; margin-bottom: 3px; }
.org-item.active {
  background: var(--accent-blue-light); color: var(--accent-blue);
  font-weight: 500;
}
.org-item.active .org-item-name { color: var(--accent-blue); }
.org-item.active .org-item-members { color: rgba(37, 99, 235, 0.7); }

.org-item-icon {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); font-weight: 600; font-size: 0.75rem;
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  color: var(--text-primary); flex-shrink: 0;
}
.org-item.active .org-item-icon { background: #fff; border-color: rgba(37, 99, 235, 0.3); color: var(--accent-blue); }

.org-item-info { flex: 1; min-width: 0; }
.org-item-name { font-size: 0.875rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-primary); }
.org-item-members { font-size: 0.75rem; color: var(--text-secondary); }

/* ===== Content Area ===== */
.content-area { flex: 1; overflow-y: auto; padding: 32px; background: var(--bg-secondary); }

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 60vh; text-align: center; gap: 16px;
}
.empty-icon svg { width: 48px; height: 48px; color: var(--border-color); }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--text-primary); }
.empty-state p { font-size: 0.875rem; color: var(--text-secondary); max-width: 300px; }

/* ===== Org View ===== */
.org-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; gap: 20px; flex-wrap: wrap;
  padding-bottom: 24px; border-bottom: 1px solid var(--border-color);
}
.org-header-info h2 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.02em; }
.org-header-info p { font-size: 0.875rem; color: var(--text-secondary); margin-top: 4px; }
.org-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.credentials-filter {
  display: flex; gap: 12px; margin-bottom: 24px; align-items: center;
  flex-wrap: wrap;
}
.search-wrapper {
  flex: 1; min-width: 240px; position: relative;
}
.search-wrapper svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-wrapper input {
  width: 100%; padding: 8px 12px 8px 36px;
  background: var(--bg-primary); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); color: var(--text-primary); font-size: 0.875rem;
  outline: none; transition: border-color var(--transition-fast);
}
.search-wrapper input:focus { border-color: var(--border-focus); background: var(--bg-secondary); }
.search-wrapper input::placeholder { color: var(--text-muted); }

.credentials-filter select {
  padding: 8px 32px 8px 12px; background: var(--bg-primary);
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  color: var(--text-primary); font-size: 0.875rem; cursor: pointer; outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234b5563' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.credentials-filter select:focus { border-color: var(--border-focus); background-color: var(--bg-secondary); }

/* ===== Credential Cards ===== */
.credentials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.credential-card {
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 20px;
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}
.credential-card:hover {
  border-color: #d1d5db;
  box-shadow: var(--shadow-md);
}

.cred-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; }
.cred-title { font-size: 1rem; font-weight: 600; color: var(--text-primary); }
.cred-category {
  font-size: 0.65rem; font-weight: 600; text-transform: uppercase;
  padding: 2px 6px; border-radius: var(--radius-sm);
  background: var(--bg-tertiary); color: var(--text-secondary); border: 1px solid var(--border-color);
}

.cred-field { margin-bottom: 12px; }
.cred-field-label { font-size: 0.65rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.cred-field-value {
  font-size: 0.875rem; color: var(--text-primary);
  display: flex; align-items: center; gap: 8px;
}
.cred-field-value.mono { font-family: var(--font-mono); font-size: 0.8125rem; }
.cred-field-value.notes { color: var(--text-secondary); font-size: 0.8125rem; line-height: 1.4; }

.cred-password-display {
  display: flex; align-items: center; gap: 8px;
}
.cred-password-dots { letter-spacing: 2px; font-size: 1rem; color: var(--text-muted); line-height: 1; }
.cred-password-text {
  font-family: var(--font-mono); font-size: 0.8125rem; font-weight: 500;
  color: var(--text-primary); word-break: break-all;
  background: var(--bg-tertiary); padding: 2px 6px; border-radius: var(--radius-sm); border: 1px solid var(--border-color);
}

.cred-actions { display: flex; gap: 8px; margin-top: 20px; }
.cred-actions .btn { font-size: 0.75rem; padding: 6px 10px; }

.cred-meta { font-size: 0.65rem; color: var(--text-muted); margin-top: 16px; text-align: right; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(17, 24, 39, 0.4); backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 20px;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 440px; max-height: 85vh; overflow-y: auto;
  padding: 24px;
  animation: slideDown 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideDown { from { transform: translateY(-10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; padding-bottom: 12px; border-bottom: 1px solid var(--border-color); }
.modal-header h3 { font-size: 1rem; font-weight: 600; color: var(--text-primary); }

.pin-modal { max-width: 320px; text-align: center; }
.pin-subtitle { font-size: 0.8125rem; color: var(--text-secondary); margin-bottom: 20px; }
.pin-input-group { margin-bottom: 16px; }
.pin-input-group input {
  width: 100%; text-align: center; font-size: 1.25rem; font-family: var(--font-mono); letter-spacing: 8px;
  padding: 12px; background: var(--bg-primary);
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  color: var(--text-primary); outline: none; transition: border-color var(--transition-fast);
}
.pin-input-group input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 2px rgba(37,99,235,0.1); }
.pin-error { color: var(--accent-red); font-size: 0.75rem; margin-bottom: 12px; font-weight: 500; }

/* ===== Members List ===== */
.member-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-color); margin-bottom: 8px; background: var(--bg-primary);
}
.member-info { display: flex; align-items: center; gap: 10px; }
.member-avatar {
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.75rem; color: var(--text-primary);
}
.member-name { font-size: 0.8125rem; font-weight: 500; color: var(--text-primary); }
.member-role { font-size: 0.7rem; color: var(--text-secondary); font-family: var(--font-mono); }
.member-badge {
  font-size: 0.6rem; font-weight: 600; text-transform: uppercase;
  padding: 2px 6px; border-radius: 2px; letter-spacing: 0.05em;
  border: 1px solid var(--border-color);
}
.member-badge.admin { background: var(--bg-secondary); color: var(--text-primary); }
.member-badge.member { background: var(--bg-tertiary); color: var(--text-secondary); border-color: transparent; }

/* ===== Toast ===== */
#toast-container {
  position: fixed; bottom: 20px; right: 20px; z-index: 999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 0.8125rem; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
  animation: toastIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 240px; max-width: 360px;
  background: var(--bg-secondary); color: var(--text-primary);
  border: 1px solid var(--border-color); box-shadow: var(--shadow-md);
}
@keyframes toastIn { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error { border-left: 3px solid var(--accent-red); }
.toast.info { border-left: 3px solid var(--accent-blue); }

.toast span:first-child { font-weight: bold; }
.toast.success span:first-child { color: var(--accent-green); }
.toast.error span:first-child { color: var(--accent-red); }
.toast.info span:first-child { color: var(--accent-blue); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .main-content { flex-direction: column; }
  .sidebar { width: 100%; min-width: 100%; border-right: none; border-bottom: 1px solid var(--border-color); }
  .org-list { display: flex; gap: 8px; overflow-x: auto; padding: 12px; flex-wrap: nowrap; }
  .org-item { min-width: 180px; margin-bottom: 0; }
  .content-area { padding: 16px; }
  .credentials-grid { grid-template-columns: 1fr; }
  .org-header { flex-direction: column; padding-bottom: 16px; }
  .nav-actions { gap: 8px; }
  .user-name { display: none; }
}

@media (max-width: 480px) {
  .auth-card { padding: 24px 20px; border: none; box-shadow: none; background: transparent; }
  .auth-wrapper { background: var(--bg-secondary); }
  .org-header-actions { width: 100%; }
  .org-header-actions .btn { flex: 1; }
  .modal { max-height: 100vh; border-radius: 0; height: 100%; border: none; }
  .modal-overlay { padding: 0; }
}

/* ===== Utilities ===== */
.add-member-row { display: flex; gap: 8px; margin-bottom: 16px; align-items: flex-start; }
.add-member-row > div { flex: 1; min-width: 0; }
.add-member-row input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}
.add-member-row input::placeholder { color: var(--text-muted); }
.add-member-row input:focus {
  background: var(--bg-secondary);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.no-credentials { text-align: center; padding: 60px 20px; color: var(--text-muted); font-size: 0.875rem; border: 1px dashed var(--border-color); border-radius: var(--radius-md); }
