/* ========================================
   Secure Vault - Modern Dark Theme CSS
   ======================================== */

:root {
  /* Colors */
  --bg-primary: #0a0e14;
  --bg-secondary: #12171f;
  --bg-tertiary: #1a2029;
  --bg-card: #1e242d;
  --bg-hover: #252d38;

  --accent-primary: #5c9aff;
  --accent-secondary: #7eb8ff;
  --accent-gradient: linear-gradient(135deg, #5c9aff 0%, #3d7dd4 100%);

  --text-primary: #ffffff;
  --text-secondary: #a0aec0;
  --text-muted: #718096;

  --success: #48bb78;
  --warning: #ed8936;
  --danger: #f56565;
  --info: #4299e1;

  --border-color: #2d3748;
  --border-radius: 12px;
  --border-radius-sm: 8px;

  /* Shadows */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(92, 154, 255, 0.3);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s ease;

  /* Sidebar */
  --sidebar-width: 260px;
}

/* Reset & Base */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  min-height: 100vh;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 600;
  line-height: 1.3;
}

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-secondary);
}

/* Loading Screen */
.loading-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  z-index: 9999;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Auth Views */
.auth-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  background-image:
    radial-gradient(circle at 20% 80%, rgba(92, 154, 255, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(92, 154, 255, 0.08) 0%, transparent 50%);
  padding: 2rem;
}

.auth-container {
  width: 100%;
  max-width: 420px;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-header .logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  background: var(--accent-gradient);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
}

.auth-header .logo svg {
  width: 36px;
  height: 36px;
  color: white;
}

.auth-header h1 {
  font-size: 1.75rem;
  margin-bottom: 0.25rem;
}

.auth-header p {
  color: var(--text-secondary);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  color: var(--text-secondary);
}

/* Form Elements */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group small {
  font-size: 0.75rem;
  color: var(--text-muted);
}

input,
select,
textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  transition: all var(--transition-fast);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(92, 154, 255, 0.2);
}

input::placeholder {
  color: var(--text-muted);
}

input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 0.9375rem;
  font-weight: 500;
  font-family: inherit;
  border: none;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn svg {
  width: 18px;
  height: 18px;
  pointer-events: none;
}

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md), var(--shadow-glow);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #e53e3e;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 0.5rem;
  position: relative;
  z-index: 1;
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-sm svg {
  width: 16px;
  height: 16px;
  pointer-events: none;
}

/* Dashboard Layout */
#dashboard-view {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
}

.sidebar-header {
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.logo-small {
  width: 40px;
  height: 40px;
  background: var(--accent-gradient);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-small svg {
  width: 22px;
  height: 22px;
  color: white;
}

.sidebar-header h2 {
  font-size: 1.125rem;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text-secondary);
  border-radius: var(--border-radius-sm);
  margin-bottom: 0.25rem;
  transition: all var(--transition-fast);
}

.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(92, 154, 255, 0.15);
  color: var(--accent-primary);
}

.nav-divider {
  height: 1px;
  background: var(--border-color);
  margin: 1rem 0;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: var(--accent-gradient);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.user-details {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.user-details span {
  font-weight: 500;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-details small {
  color: var(--text-muted);
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 1.5rem 2rem;
  background: var(--bg-primary);
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.content-header h1 {
  font-size: 1.75rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.search-box {
  position: relative;
  width: 280px;
}

.search-box svg {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.search-box input {
  padding-left: 2.75rem;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  border: 1px solid var(--border-color);
  transition: all var(--transition-fast);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card.small {
  padding: 1rem;
  flex-direction: column;
  text-align: center;
  gap: 0.5rem;
}

.stat-card.small h4 {
  font-size: 2rem;
  color: var(--accent-primary);
}

.stat-card.small p {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.stat-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon svg {
  width: 28px;
  height: 28px;
  color: white;
}

.stat-icon.vpn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.stat-icon.sap {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.stat-icon.cred {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.stat-info h3 {
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.stat-info p {
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

/* Items Grid */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.item-card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 1.25rem;
  border: 1px solid var(--border-color);
  transition: all var(--transition-fast);
}

.item-card:hover {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
}

.item-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.item-card-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.item-card-icon {
  width: 40px;
  height: 40px;
  background: var(--bg-hover);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.item-card-icon svg {
  width: 20px;
  height: 20px;
  color: var(--accent-primary);
}

.item-card-title h4 {
  font-size: 1rem;
}

.item-card-title small {
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.item-card-actions {
  display: flex;
  gap: 0.25rem;
}

.item-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.item-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: var(--bg-tertiary);
  border-radius: var(--border-radius-sm);
  font-size: 0.875rem;
}

.item-field label {
  color: var(--text-muted);
}

.item-field span {
  font-family: monospace;
}

.item-field .password-hidden {
  letter-spacing: 2px;
}

/* Table */
.items-table-container {
  overflow-x: auto;
}

.items-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-card);
  border-radius: var(--border-radius);
  overflow: hidden;
}

.items-table th,
.items-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.items-table th {
  background: var(--bg-tertiary);
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.items-table tbody tr {
  transition: background var(--transition-fast);
}

.items-table tbody tr:hover {
  background: var(--bg-hover);
}

.items-table tbody tr.clickable-row {
  cursor: pointer;
  transition: background var(--transition-fast);
}

.items-table tbody tr.clickable-row:hover {
  background: rgba(92, 154, 255, 0.1);
}

.items-table tbody tr:last-child td {
  border-bottom: none;
}

.items-table .empty-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
}

/* Settings */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.5rem;
}

.settings-card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  border: 1px solid var(--border-color);
}

.settings-card h3 {
  font-size: 1.125rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.settings-card .form-group {
  margin-bottom: 1rem;
}

/* Admin */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.admin-actions {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.users-table-container {
  overflow-x: auto;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 999px;
}

.badge-success {
  background: rgba(72, 187, 120, 0.15);
  color: var(--success);
}

.badge-warning {
  background: rgba(237, 137, 54, 0.15);
  color: var(--warning);
}

.badge-danger {
  background: rgba(245, 101, 101, 0.15);
  color: var(--danger);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  backdrop-filter: blur(4px);
}

.modal.show {
  display: flex;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  font-size: 1.25rem;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
}

.modal-body .form-group {
  margin-bottom: 1rem;
}

.modal-body .form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

/* Toast */
#toast-container {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 2000;
  display: flex;
  flex-direction: column-reverse;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-card);
  border-radius: var(--border-radius-sm);
  padding: 1rem 1.25rem;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 280px;
  max-width: 400px;
  animation: slideIn 0.3s ease;
}

.toast.success {
  border-color: var(--success);
}

.toast.error {
  border-color: var(--danger);
}

.toast.warning {
  border-color: var(--warning);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
  grid-column: 1 / -1;
}

/* Recent Section */
.recent-section h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

/* Responsive */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }
}

@media (max-width: 640px) {
  .auth-container {
    padding: 1.5rem;
  }

  .content-header {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .items-grid {
    grid-template-columns: 1fr;
  }
}

/* Clickable Item Cards */
.item-card.clickable {
  cursor: pointer;
  transition: all var(--transition-fast);
}

.item-card.clickable:hover {
  transform: translateY(-2px);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md), 0 0 0 1px var(--accent-primary);
}

.item-card-footer {
  padding-top: 0.75rem;
  margin-top: 0.75rem;
  border-top: 1px solid var(--border-color);
  text-align: center;
}

.view-details {
  font-size: 0.75rem;
  color: var(--accent-primary);
  opacity: 0.7;
  transition: opacity var(--transition-fast);
}

.item-card.clickable:hover .view-details {
  opacity: 1;
}

/* Detail View Modal */
.detail-view {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.detail-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.detail-field label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.detail-value {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg-tertiary);
  border-radius: var(--border-radius-sm);
  font-family: 'JetBrains Mono', monospace;
}

.detail-value span {
  flex: 1;
  word-break: break-all;
}

.detail-value a {
  flex: 1;
  word-break: break-all;
}

.detail-row {
  display: flex;
  gap: 1rem;
}

.detail-field.half {
  flex: 1;
}

.detail-notes {
  padding: 0.75rem 1rem;
  background: var(--bg-tertiary);
  border-radius: var(--border-radius-sm);
  white-space: pre-wrap;
  color: var(--text-secondary);
}

.password-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.password-hidden {
  letter-spacing: 3px;
  color: var(--text-muted);
}

.copy-btn {
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}

.copy-btn:hover {
  opacity: 1;
}

/* Button inside detail value */
.detail-value .btn {
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .detail-row {
    flex-direction: column;
    gap: 1rem;
  }
}

/* SAProuter field with special styling */
.saprouter-field {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border-color);
}

.saprouter-field label {
  color: var(--accent-primary);
}

/* Tabs */
.tabs {
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  overflow: hidden;
  margin-bottom: 1rem;
}

.tab-header {
  display: flex;
  background: var(--bg-tertiary);
  padding: 0.5rem;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.tab-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--accent-gradient);
  color: white;
  box-shadow: var(--shadow-sm), var(--shadow-glow);
}

.tab-content {
  padding: 1.5rem;
}

/* Pending Badge for Admin Nav */
.pending-badge {
  background: var(--warning);
  color: #000;
  font-size: 0.7rem;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  animation: pulse-warning 1.5s ease-in-out infinite;
}

@keyframes pulse-warning {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.7;
    transform: scale(1.1);
  }
}