/* ==========================================
   OPLEX - MODUŁ ERLI
   Dark theme contract v1.0
   ========================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:            #181818;
  --card-bg:       #1e1e1e;
  --border:        rgba(255,255,255,0.06);
  --border-hover:  rgba(255,255,255,0.10);
  --text-primary:  #e5e7eb;
  --text-secondary:#9ca3af;
  --text-muted:    #6b7280;
  --radius:        0px;
  --primary:       #3b82f6;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}

::-webkit-scrollbar        { width: 6px; height: 6px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: rgba(255,255,255,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.14); }

/* === TOP BAR === */
.topbar {
  position: sticky;
  top: 0;
  height: 56px;
  background: #202020;
  border-bottom: 1px solid rgba(59,130,246,0.15);
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
}

.topbar-left  { display: flex; align-items: center; gap: 10px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.topbar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
}

.topbar-title .ui-icon {
  width: 20px;
  height: 20px;
  stroke: #9ca3af;
}

.topbar-text { color: var(--text-primary); }

.topbar-action {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 0;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  transition: color 150ms, border-color 150ms, background 150ms;
}

.topbar-action:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
  background: rgba(255,255,255,0.04);
}

.topbar-icon {
  width: 16px; height: 16px;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

.ui-icon {
  width: 16px; height: 16px;
  fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}

/* === LAYOUT === */
.erli-layout {
  display: flex;
  height: calc(100vh - 56px);
}

.erli-content {
  flex: 1;
  height: 100%;
  overflow-y: auto;
  padding: 28px 32px;
  background: var(--bg);
  overscroll-behavior-y: contain;
}

.erli-content > div[id] {
  max-width: 1600px;
  margin: 0 auto;
}

/* === SIDEBAR — allegro pattern === */
.erli-sidebar {
  position: sticky;
  top: 0;
  width: 64px;
  height: 100%;
  background: #1c1c1c;
  display: flex;
  flex-direction: column;
  padding: 16px 0;
  transition: width 180ms ease;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 2px 0 12px rgba(0,0,0,0.35);
}

.erli-sidebar::after {
  content: "";
  position: absolute;
  top: 0; right: 0;
  width: 1px; height: 100%;
  background: linear-gradient(
    to bottom,
    rgba(59,130,246,0.15),
    rgba(59,130,246,0.35),
    rgba(59,130,246,0.15)
  );
  pointer-events: none;
  opacity: 0.4;
  transform: scaleY(0.85);
  transition: opacity 180ms ease, transform 220ms ease;
}

.erli-sidebar:hover::after {
  opacity: 0.9;
  transform: scaleY(1);
}

.erli-sidebar:hover { width: 220px; }

.erli-sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.erli-sidebar .sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
  opacity: 0.7;
  transition: opacity 150ms ease, background-color 150ms ease;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.erli-sidebar .sidebar-item:hover {
  opacity: 1;
  background: rgba(255,255,255,0.05);
}

.erli-sidebar .sidebar-item.active {
  opacity: 1;
  background: rgba(59,130,246,0.15);
  border-left: 3px solid var(--primary);
  box-shadow: inset 0 0 0 1px rgba(59,130,246,0.25), 0 0 12px rgba(59,130,246,0.12);
}

.erli-sidebar .icon {
  width: 18px; height: 18px;
  stroke: var(--text-secondary);
  stroke-width: 1.8; fill: none;
  flex-shrink: 0;
}

.erli-sidebar .sidebar-item.active .icon { stroke: var(--primary); }

.erli-sidebar .label {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
  display: none;
}

.erli-sidebar .sidebar-item.active .label { font-weight: 600; }
.erli-sidebar:hover .label { display: inline; }

/* === MAIN CARD === */
.premium-card,
.costs-erli-sync-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 22px;
  transition: border-color 180ms, box-shadow 180ms;
}

.premium-card:hover,
.costs-erli-sync-card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

/* === CARD HEADER === */
.costs-erli-sync-header {
  margin-bottom: 20px;
}

.costs-erli-sync-header h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.costs-erli-sync-header h3 .ui-icon { stroke: #60a5fa; }

.costs-erli-sync-header p {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* === ACTIONS ROW === */
.costs-erli-sync-actions {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

/* === PERIOD PICKER — strip the shared card container === */
.billing-period-card {
  background: none !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  box-shadow: none !important;
  min-width: 0 !important;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.billing-period-card:hover {
  border: none !important;
  box-shadow: none !important;
}

.period-card-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.billing-period-input {
  background: rgba(255,255,255,0.04) !important;
  border: 1px solid rgba(255,255,255,0.08) !important;
  border-radius: 0 !important;
  -webkit-appearance: none;
  appearance: none;
  padding: 9px 12px !important;
  color: var(--text-primary) !important;
  font-size: 0.875rem !important;
  font-family: inherit !important;
  outline: none;
  transition: border-color 150ms !important;
  box-shadow: none !important;
}

.billing-period-input:focus {
  border-color: rgba(59,130,246,0.5) !important;
  background: rgba(59,130,246,0.04) !important;
  box-shadow: none !important;
}

/* === BUTTONS === */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: rgba(59,130,246,0.10);
  color: #60a5fa;
  border: 1.5px solid rgba(59,130,246,0.35);
  border-radius: 0;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 180ms, box-shadow 180ms;
  white-space: nowrap;
}

.btn-primary:hover:not(:disabled) {
  background: rgba(59,130,246,0.18);
  box-shadow: 0 2px 10px rgba(59,130,246,0.2);
}

.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: rgba(255,255,255,0.04);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
  border-radius: 0;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 180ms, color 180ms, border-color 180ms;
  white-space: nowrap;
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }

/* === STATUS === */
.costs-erli-preview-status {
  padding: 12px 16px;
  border-radius: 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.costs-erli-preview-status.status-success {
  color: #34d399;
  background: rgba(52,211,153,0.08);
  border-color: rgba(52,211,153,0.2);
}

.costs-erli-preview-status.status-error {
  color: #f87171;
  background: rgba(248,113,113,0.08);
  border-color: rgba(248,113,113,0.2);
}

.costs-erli-preview-status.status-warning {
  color: #fbbf24;
  background: rgba(251,191,36,0.08);
  border-color: rgba(251,191,36,0.2);
}

/* === SUMMARY GRID === */
.costs-erli-preview-summary {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.summary-item {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.summary-item .label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.summary-item .value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.summary-item--danger {
  border-color: rgba(248,113,113,0.25);
  background: rgba(248,113,113,0.06);
}

.summary-item--danger .value { color: #f87171; }

.summary-item-wide { grid-column: 1 / -1; }

/* === TABLES === */
.billing-table-caption {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 24px 0 10px;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.history-table th {
  padding: 9px 14px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
}

.history-table td {
  padding: 10px 14px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}

.history-table tbody tr:last-child td { border-bottom: none; }
.history-table tbody tr:hover td { background: rgba(255,255,255,0.02); }

.amount-charge { color: #34d399; font-weight: 600; }
.amount-credit  { color: #f87171; font-weight: 600; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .erli-content { padding: 20px 16px; }
  .costs-erli-sync-actions { flex-direction: column; align-items: stretch; }
  .btn-primary, .btn-secondary { justify-content: center; }
  .costs-erli-preview-summary { grid-template-columns: 1fr 1fr; }
}
