/**
 * Világmegváltó (VM) - Global Application Styles
 * Vanilla CSS Architecture
 */

@import "variables.css";

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--color-bg-base);
  color: var(--color-text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: 700;
  line-height: 1.25;
  color: var(--color-text-primary);
  letter-spacing: -0.01em;
}

h1 { font-size: 1.75rem; margin-bottom: 0.75rem; }
h2 { font-size: 1.35rem; margin-bottom: 0.5rem; }
h3 { font-size: 1.15rem; margin-bottom: 0.35rem; }

p {
  margin-bottom: 1rem;
}

a {
  color: var(--color-primary-accent);
  text-decoration: none;
  transition: color 0.15s ease, opacity 0.15s ease;
}

a:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

.text-mono {
  font-family: var(--font-mono);
}

.text-muted {
  color: var(--color-text-muted);
}

.text-center {
  text-align: center;
}

/* Layout Containers */
.app-container {
  width: 100%;
  max-width: var(--max-content-width);
  margin: 0 auto;
  padding: var(--grid-gap-base);
  flex: 1;
}

/* Sticky Header & Navigation */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: var(--color-bg-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
}

.nav-container {
  width: 100%;
  max-width: var(--max-content-width);
  margin: 0 auto;
  padding: 0 var(--grid-gap-base);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--color-text-primary);
  font-weight: 800;
  font-size: 1.15rem;
}

.brand-link:hover {
  text-decoration: none;
}

.brand-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.brand-name {
  display: inline-block;
  white-space: nowrap;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--border-radius-sm);
  color: var(--color-text-muted);
  transition: all 0.15s ease;
  text-decoration: none;
}

.nav-action-btn:hover {
  color: var(--color-text-primary);
  background: var(--color-neutral-shaded);
  text-decoration: none;
}

.nav-action-btn.active {
  color: var(--color-primary-accent);
  background: rgba(61, 90, 128, 0.08);
}

.nav-logout-btn:hover {
  color: var(--color-destructive);
  background: var(--color-destructive-bg);
}

.nav-user-badge {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-primary);
  background: transparent;
  padding: 0 8px;
  height: 36px;
  border-radius: var(--border-radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: color 0.15s ease;
}

.nav-user-badge:hover {
  background: transparent;
  color: var(--color-primary-accent);
  text-decoration: none;
}

.nav-user-badge.active {
  background: transparent;
  color: var(--color-primary-accent);
}

/* Cards & Panels */
.card {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.card-header {
  padding: 14px 18px;
  background: var(--color-bg-surface);
  border-bottom: 1px solid var(--color-border);
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body {
  padding: 18px;
}

.card-footer {
  padding: 12px 18px;
  background: var(--color-neutral-shaded);
  border-top: 1px solid var(--color-border);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--interactive-height);
  padding: 0 18px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--border-radius-sm);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background-color: var(--color-primary-accent);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--color-primary-hover);
  color: #ffffff;
  text-decoration: none;
}

.btn-secondary {
  background-color: var(--color-bg-base);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background-color: var(--color-neutral-shaded);
  border-color: var(--color-border-hover);
  text-decoration: none;
}

.btn-success {
  background-color: var(--color-success);
  color: #113615;
}

.btn-success:hover {
  background-color: #7ab878;
  text-decoration: none;
}

.btn-danger {
  background-color: var(--color-destructive);
  color: #ffffff;
}

.btn-danger:hover {
  background-color: #d85739;
  text-decoration: none;
}

.btn-sm {
  height: 34px;
  padding: 0 12px;
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
}

/* Badges & Tags */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--border-radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-primary { background: rgba(61, 90, 128, 0.15); color: var(--color-primary-accent); }
.badge-secondary { background: rgba(152, 193, 217, 0.3); color: #214e6b; }
.badge-success { background: var(--color-success-bg); color: #1e5a23; }
.badge-warning { background: var(--color-highlight-bg); color: #7a6e12; }
.badge-danger { background: var(--color-destructive-bg); color: var(--color-destructive); }

/* Forms & Inputs */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--color-text-primary);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  height: var(--interactive-height);
  padding: 0 14px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--color-text-primary);
  background-color: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-textarea {
  height: auto;
  min-height: 100px;
  padding: 10px 14px;
  resize: vertical;
}

.form-input:hover, .form-select:hover, .form-textarea:hover {
  border-color: var(--color-border-hover);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--color-primary-accent);
  box-shadow: 0 0 0 2px rgba(61, 90, 128, 0.15);
}

/* Tables */
.table-container {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-bg-surface);
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

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

.table th {
  background: var(--color-neutral-shaded);
  font-weight: 700;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.table tr:last-child td {
  border-bottom: none;
}

.table tr:hover td {
  background: rgba(26, 26, 26, 0.02);
}

/* Toast System */
.toast-container {
  position: fixed;
  top: 75px;
  right: var(--grid-gap-base);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  min-width: 280px;
  max-width: 380px;
  padding: 14px 18px;
  border-radius: var(--border-radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast-success {
  background: hsla(142, 70%, 95%, 0.98);
  color: #155724;
  border: 1px solid #c3e6cb;
}

.toast-error {
  background: hsla(0, 85%, 97%, 0.98);
  color: #721c24;
  border: 1px solid #f5c6cb;
}

@keyframes toastSlideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Footer */
.app-footer {
  margin-top: auto;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-surface);
  padding: 20px 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* Mobile Breakpoints */
@media (max-width: 768px) {
  .nav-user {
    display: flex;
    gap: 4px;
  }

  .nav-user-name {
    display: none;
  }

  .nav-user-badge {
    padding: 0;
    width: 36px;
    height: 36px;
    justify-content: center;
  }

  .brand-name {
    font-size: 1.15rem;
  }

  .brand-link {
    gap: 8px;
  }

  .brand-logo {
    width: 32px;
    height: 32px;
  }

  .app-container {
    padding: 14px;
  }
}

/* ==========================================================================
   Modals & Popup Windows (Sticky Header/Footer & Scrollable Body)
   ========================================================================== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 99999;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.2s ease;
  overflow: hidden;
  box-sizing: border-box;
}

.modal-dialog {
  display: flex !important;
  flex-direction: column !important;
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-base);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow: hidden !important;
  transform: translateY(-10px);
  transition: transform 0.2s ease;
  box-sizing: border-box;
}

.modal-form {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

.modal-header {
  flex-shrink: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 16px 20px !important;
  border-bottom: 1px solid var(--color-border) !important;
  background: var(--color-bg-surface) !important;
  z-index: 2;
}

.modal-body {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  overscroll-behavior: contain !important;
  padding: 20px !important;
}

.modal-footer {
  flex-shrink: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 8px !important;
  padding: 14px 20px !important;
  border-top: 1px solid var(--color-border) !important;
  background: var(--color-bg-surface) !important;
  z-index: 2;
}

@media (max-width: 680px) {
  .modal-overlay {
    padding: 8px !important;
    align-items: center !important;
  }

  .modal-dialog {
    max-height: calc(100dvh - 16px) !important;
  }

  .modal-header {
    padding: 12px 14px !important;
  }

  .modal-body {
    padding: 14px !important;
  }

  .modal-footer {
    padding: 12px 14px !important;
  }
}

