
/* Kontrak - Global Styles */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #0a0a0a;
  color: #fff;
  min-height: 100vh;
}

a { color: #fff; text-decoration: none; }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 220px;
  background: #111;
  border-right: 1px solid #222;
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .logo {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 3px;
  color: #fff;
  padding: 0 24px 24px;
  border-bottom: 1px solid #222;
  margin-bottom: 16px;
}
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 24px;
  color: #999;
  font-size: .92rem;
  border-left: 3px solid transparent;
  transition: all .15s;
}
.sidebar nav a:hover, .sidebar nav a.active {
  color: #fff;
  background: #1a1a1a;
  border-left-color: #fff;
}
.sidebar .user-section {
  margin-top: auto;
  padding: 16px 24px;
  border-top: 1px solid #222;
  font-size: .82rem;
  color: #666;
}
.sidebar .user-section button {
  margin-top: 8px;
  background: none;
  border: 1px solid #333;
  color: #999;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: .82rem;
  width: 100%;
}
.sidebar .user-section button:hover { border-color: #fff; color: #fff; }

/* Main content */
.main-content {
  margin-left: 220px;
  flex: 1;
  padding: 32px;
}

/* Page header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}
.page-header h1 { font-size: 1.6rem; font-weight: 700; }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: #111;
  border: 1px solid #222;
  border-radius: 10px;
  padding: 20px;
  height: fit-content;
}
.stat-card .label { color: #666; font-size: .82rem; text-transform: uppercase; letter-spacing: 1px; }
.stat-card .value { font-size: 2rem; font-weight: 700; margin-top: 6px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity .15s;
}
.btn:hover { opacity: .85; }
.btn-primary { background: #fff; color: #000; }
.btn-secondary { background: #1a1a1a; color: #fff; border: 1px solid #333; }
.btn-danger { background: #3a1a1a; color: #ff6b6b; border: 1px solid #5a2a2a; }

/* Table */
.table-wrap {
  background: #111;
  border: 1px solid #222;
  border-radius: 10px;
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
th {
  background: #0a0a0a;
  padding: 12px 16px;
  text-align: left;
  font-size: .8rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid #222;
}
td {
  padding: 14px 16px;
  border-bottom: 1px solid #1a1a1a;
  font-size: .9rem;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #161616; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #111;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 { margin-bottom: 24px; font-size: 1.2rem; }

/* Form */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; color: #999; font-size: .85rem; margin-bottom: 6px; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  color: #fff;
  font-size: .95rem;
  outline: none;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: #fff; }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-group select option { background: #1a1a1a; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* Badge */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.badge-green { background: #1a3a1a; color: #4caf50; }
.badge-yellow { background: #3a3a1a; color: #ffc107; }
.badge-blue { background: #1a2a3a; color: #64b5f6; }
.badge-gray { background: #1a1a1a; color: #999; }
.badge-red { background: #3a1a1a; color: #ef5350; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #444;
}
.empty-state p { font-size: 1rem; margin-top: 8px; }

/* Action buttons in table */
.action-btns { display: flex; gap: 8px; }
.action-btns button {
  background: none;
  border: 1px solid #333;
  color: #999;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: .8rem;
}
.action-btns button:hover { border-color: #fff; color: #fff; }
.action-btns button.del:hover { border-color: #ff6b6b; color: #ff6b6b; }

/* Search bar */
.search-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}
.search-bar input {
  flex: 1;
  padding: 10px 16px;
  background: #111;
  border: 1px solid #222;
  border-radius: 8px;
  color: #fff;
  font-size: .9rem;
  outline: none;
}
.search-bar input:focus { border-color: #444; }

/* Loading spinner */
.loading-spinner {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 60px 20px;
}
.loading-spinner::after {
  content: '';
  width: 32px;
  height: 32px;
  border: 3px solid #333;
  border-top-color: #10b981;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast notifications */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  color: #fff;
  animation: slideIn 0.3s ease;
  max-width: 360px;
}
.toast-success { background: #064e3b; border: 1px solid #10b981; }
.toast-error { background: #7f1d1d; border: 1px solid #f87171; }
.toast-info { background: #1e3a5f; border: 1px solid #60a5fa; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Confirmation modal */
.confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}
.confirm-overlay.open { display: flex; }
.confirm-box {
  background: #111;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 32px;
  max-width: 400px;
  width: 90%;
  text-align: center;
}
.confirm-box h3 { font-size: 1.1rem; margin-bottom: 12px; color: #fff; }
.confirm-box p { color: #999; font-size: 0.9rem; margin-bottom: 24px; }
.confirm-actions { display: flex; gap: 12px; justify-content: center; }

/* Form validation */
.form-group input.invalid,
.form-group select.invalid,
.form-group textarea.invalid {
  border-color: #ef4444;
}
.form-group .field-error {
  color: #ef4444;
  font-size: 0.78rem;
  margin-top: 4px;
  display: none;
}
.form-group .field-error.show { display: block; }
.form-group input.valid,
.form-group select.valid,
.form-group textarea.valid {
  border-color: #10b981;
}

/* Mobile nav toggle */
.mobile-nav-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1100;
  background: #111;
  border: 1px solid #333;
  color: #fff;
  font-size: 1.4rem;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  line-height: 1;
}

.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
}
.mobile-overlay.open { display: block; }

/* Responsive */
@media (max-width: 768px) {
  .mobile-nav-toggle { display: block; }

  .sidebar {
    width: 260px;
    transform: translateX(-260px);
    transition: transform 0.3s ease;
    z-index: 1050;
  }
  .sidebar.open { transform: translateX(0); }

  .main-content {
    margin-left: 0;
    padding: 60px 16px 16px;
  }

  .page-header { flex-direction: column; gap: 12px; align-items: flex-start; }
  .page-header h1 { font-size: 1.3rem; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card .value { font-size: 1.4rem; }

  .form-row { grid-template-columns: 1fr; }

  /* Make tables horizontally scrollable */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Stack action buttons vertically on mobile */
  .action-btns { flex-direction: column; gap: 6px; }
  .action-btns button { width: 100%; text-align: center; }

  .search-bar { flex-direction: column; }

  .modal { margin: 16px; padding: 20px; max-height: 85vh; }

  .btn { padding: 12px 18px; font-size: 1rem; }
}

/* Activity log */
.activity-item {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid #1a1a1a;
}
.activity-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}
.activity-dot.created { background: #10b981; }
.activity-dot.updated { background: #3b82f6; }
.activity-dot.deleted { background: #ef4444; }
.activity-dot.signed { background: #8b5cf6; }
.activity-dot.sent { background: #f59e0b; }
.activity-dot.exported { background: #06b6d4; }
.activity-dot.viewed { background: #666; }

/* Chart containers responsive */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 24px; }
.chart-card { background: #111; border: 1px solid #222; border-radius: 10px; padding: 28px; }
.chart-card-full { grid-column: 1 / -1; }

/* Notification panel responsive */
@media (max-width: 768px) {
  #notif-panel { width: 100% !important; }
}

/* Small phones */
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { padding: 14px; }
}

@media (max-width: 768px) {
  .chart-grid { grid-template-columns: 1fr; }
}

/* Help center */
.help-card {
  background: #111;
  border: 1px solid #222;
  border-radius: 10px;
  padding: 20px 24px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.help-card:hover { border-color: #333; }
.help-card h3 { font-size: 1rem; font-weight: 600; }
.help-content {
  display: none;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #222;
  font-size: 0.9rem;
  color: #999;
  line-height: 1.7;
}
.help-card.open .help-content { display: block; }
.help-content p { margin-bottom: 12px; }
.help-content strong { color: #ccc; }
.help-content a { color: #10b981; }
.help-content ul, .help-content ol { padding-left: 20px; }

/* App footer */
.app-footer {
  margin-top: 48px;
  padding: 24px 0;
  border-top: 1px solid #1a1a1a;
  text-align: center;
  font-size: 0.75rem;
  color: #444;
}
.app-footer a { color: #555; text-decoration: none; }
.app-footer a:hover { color: #10b981; }
