/* Andrej Kavka s.p. - Admin Panel Styling */
:root {
  --bg-main: #0b1120;
  --bg-sidebar: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #243247;
  --border-color: #334155;
  --border-focus: #f59e0b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-primary: #f59e0b;
  --accent-primary-hover: #d97706;
  --accent-blue: #38bdf8;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.2);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.4);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
}

/* Auth Overlay / Modal */
#authOverlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 17, 32, 0.95);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.auth-card {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-header h1 {
  font-size: 1.5rem;
  color: var(--text-main);
  margin-top: 0.5rem;
}

.auth-header p {
  color: var(--text-muted);
  font-size: 0.875rem;
}

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

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-brand h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.sidebar-brand span {
  font-size: 0.75rem;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
}

.sidebar-nav {
  padding: 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex-grow: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.925rem;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.nav-link:hover {
  background: var(--bg-card);
  color: var(--text-main);
}

.nav-link.active {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-primary);
  font-weight: 600;
  border-left: 3px solid var(--accent-primary);
}

.nav-link .icon {
  font-size: 1.2rem;
  width: 24px;
  text-align: center;
}

.sidebar-footer {
  padding: 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 0.875rem;
  font-weight: 600;
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Main Content Area */
.main-wrapper {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  overflow-y: auto;
  height: 100vh;
}

.topbar {
  padding: 1.25rem 2rem;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar h1 {
  font-size: 1.35rem;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.content-body {
  padding: 2rem;
  flex-grow: 1;
}

/* Tab Panels */
.tab-panel {
  display: none;
  animation: fadeIn 0.25s ease-in-out;
}

.tab-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* KPI Cards Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}

.stat-card .label {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.stat-card .value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
}

.stat-card .badge-icon {
  font-size: 2rem;
  opacity: 0.8;
}

/* Cards & Sections */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Tables */
.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  padding: 0.75rem 1rem;
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
  color: var(--text-main);
}

.data-table tr:hover td {
  background: var(--bg-card-hover);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-new { background: rgba(56, 189, 248, 0.2); color: var(--accent-blue); }
.badge-progress { background: rgba(245, 158, 11, 0.2); color: var(--accent-primary); }
.badge-done { background: rgba(16, 185, 129, 0.2); color: var(--accent-green); }
.badge-rejected { background: rgba(239, 68, 68, 0.2); color: var(--accent-red); }

/* Forms & Inputs */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-control {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.925rem;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

.form-control:focus {
  border-color: var(--border-focus);
}

.form-control[readonly], .form-control:disabled {
  background: rgba(15, 23, 42, 0.4);
  color: var(--text-muted);
  cursor: not-allowed;
}

textarea.form-control {
  min-height: 90px;
  resize: vertical;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  text-decoration: none;
}

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

.btn-primary:hover {
  background: var(--accent-primary-hover);
}

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

.btn-secondary:hover {
  background: var(--bg-card-hover);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.2);
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: var(--accent-red);
  color: #fff;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
}

/* Security Box / SMTP Lock Box */
.security-banner {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.security-banner.locked {
  border-left: 4px solid var(--accent-red);
}

.security-banner.unlocked {
  border-left: 4px solid var(--accent-green);
  background: rgba(16, 185, 129, 0.05);
}

.security-info h4 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.security-info p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Categories Tree */
.tree-node {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
  padding: 1rem;
}

.tree-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.subcategories-list {
  margin-top: 0.75rem;
  padding-left: 1.5rem;
  border-left: 2px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.subcat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Toasts */
#toastContainer {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 10000;
}

.toast {
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #fff;
  min-width: 280px;
}

.toast.success { background: #065f46; border: 1px solid #10b981; }
.toast.error { background: #7f1d1d; border: 1px solid #ef4444; }
.toast.info { background: #1e3a8a; border: 1px solid #3b82f6; }

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

@media (max-width: 768px) {
  .app-container { flex-direction: column; }
  .sidebar { width: 100%; height: auto; }
  .content-body { padding: 1rem; }
}

/* Media Gallery in Reference Modal */
.media-dropzone:hover, .media-dropzone.dragover {
  border-color: var(--accent-primary) !important;
  background: rgba(245, 158, 11, 0.06) !important;
}

.media-tile {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.media-tile:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
}

.media-tile.is-cover {
  border: 2px solid var(--accent-primary);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.25);
}

.media-preview-box {
  width: 100%;
  height: 95px;
  background: #090e17;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.media-preview-box img, .media-preview-box video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-type-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 0.65rem;
  padding: 2px 5px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
}

.media-cover-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--accent-primary);
  color: #000;
  font-size: 0.65rem;
  font-weight: bold;
  padding: 2px 5px;
  border-radius: 4px;
}

.media-tile-footer {
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  background: rgba(15, 23, 42, 0.9);
  border-top: 1px solid var(--border-color);
}

.media-sort-input {
  width: 44px;
  padding: 2px 4px;
  font-size: 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: 4px;
  text-align: center;
}

.media-btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 0.85rem;
  border-radius: 4px;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-btn-icon:hover {
  color: var(--accent-red);
  background: rgba(239, 68, 68, 0.15);
}

.media-btn-cover:hover {
  color: var(--accent-primary);
  background: rgba(245, 158, 11, 0.15);
}
