/* Base theme and atoms extracted from base.html */
:root {
  /* Dark theme (not black) */
  --bg: #161a20;
  /* Slightly deeper panel tones for clearer separation */
  --bg2: #1d232b;   /* was #20262e */
  --bg3: #262c34;   /* was #2a3038 */
  --fg: #e7eaee;
  --muted: #a4aebd;
  /* Primary: teal with a blueish tint; Secondary: orange accent */
  --primary: #11b3d5;
  --primary-600: #0a8fb1;
  --secondary: #f97316;
  --secondary-600: #ea580c;
  /* Stronger focus ring for accessibility */
  --ring: rgba(17,179,213,.55); /* was .40 */
  /* Brighter border for higher contrast on dark surfaces */
  --border: #4a5663; /* was #3a444f */
  --radius: 12px;
  --radius-sm: 10px;
  --shadow-1: 0 1px 2px rgba(0,0,0,.45), 0 8px 22px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: linear-gradient(180deg, var(--bg) 0%, #2a2f36 100%);
  color: var(--fg);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--primary); text-decoration: none; }
/* Do not restyle anchor buttons or nav pills on hover */
a:not(.btn):not(.nav-link):hover { color: var(--primary-600); text-decoration: underline; }

header {
  background: rgba(23,26,32,.85);
  backdrop-filter: saturate(140%) blur(6px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.nav {
  max-width: 1120px; margin: 0 auto;
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand {
  font-weight: 700; letter-spacing: .2px;
  color: var(--fg);
}
.brand:hover { text-decoration: none; filter: brightness(1.08); }

/* Top navigation: desktop */
.topnav {
  display: flex; align-items: center; gap: 8px;
}
.topnav .nav-link, .topnav .nav-logout {
  display: inline-flex; align-items: center; justify-content: center;
  height: 32px;
  min-height: 32px; /* override global button min-height:40px so Logout matches */
  padding: 0 10px;
  color: var(--fg);
  background: linear-gradient(180deg, var(--bg2), var(--bg3));
  border: 1px solid var(--border);
  border-radius: 9999px;
  transition: background .12s ease, border-color .12s ease, color .12s ease, box-shadow .12s ease, transform .05s ease;
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
}
.topnav .nav-link:hover, .topnav .nav-logout:hover {
  border-color: var(--primary);
  color: #fff;
  background: #22303a;
}
.topnav .nav-link.active {
  color: #fff;
  background: #0f1b22;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--ring);
}
/* Focus ring for keyboard users on nav items */
.topnav .nav-link:focus-visible, .topnav .nav-logout:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

/* Compact menu toggle (hidden on desktop) */
.icon-btn.nav-toggle { display: none; }

/* Responsive behavior */
@media (max-width: 768px) {
  .nav { flex-wrap: wrap; }
  .icon-btn.nav-toggle { display: inline-flex; margin-left: auto; }
  .topnav {
    width: 100%;
    display: none;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
  }
  .topnav[data-state="open"] { display: flex; flex-wrap: wrap; }
  .topnav .nav-link, .topnav .nav-logout { flex: 1 1 auto; justify-content: center; }
}
.container { max-width: 1120px; margin: 0 auto; padding: 20px 16px; }

h1 { font-size: 28px; line-height: 1.2; margin: 0 0 8px; }
h2 { font-size: 22px; line-height: 1.25; margin: 0 0 8px; }
.muted { color: var(--muted); }

.card {
  background: linear-gradient(180deg, var(--bg2), var(--bg3));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-1);
}
.surface {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary);
  color: #fff;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  min-height: 40px;            /* unify height across anchors and buttons */
  cursor: pointer;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;       /* keep anchors styled like buttons */
  appearance: none;
  -webkit-appearance: none;    /* neutralize UA styles for button elements */
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, filter .15s ease;
}
button:hover, .btn:hover { background: var(--primary-600); }
/* Strong focus ring for keyboard users; keeps contrast on anchor .btn as well */
button:focus-visible, .btn:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}
.btn-outline {
  background: transparent;
  color: var(--fg);
  border-color: var(--border);
}
.btn-outline:hover { border-color: var(--primary); color: #fff; }
.btn-outline:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

/* Secondary (orange) accent button */
.btn-secondary {
  background: var(--secondary);
}
.btn-secondary:hover {
  background: var(--secondary-600);
}

label { display: block; margin: 10px 0 6px; color: var(--muted); font-size: 14px; }
input[type="text"], input[type="password"], input[type="email"], select, textarea {
  width: 100%;
  background: var(--bg2); /* lighter dark vs black */
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
  background: #1f2730; /* subtle raise on focus for contrast */
}
.field-inline { display: flex; gap: 12px; flex-wrap: wrap; }
.field-inline > * { min-width: 160px; flex: 1; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; border-top: 1px solid var(--border); text-align: left; }
.table thead th { background: #12171e; border-bottom: 1px solid var(--border); color: var(--muted); font-weight: 600; }
.table tbody tr:hover { background: #0f151c; }

/* Small square icon buttons (used across toolbars) */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--bg2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: background .12s ease, color .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.icon-btn:hover {
  background: #22303a;            /* clearer hover */
  color: #fff;
  border-color: var(--primary);
}
.icon-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
  border-color: var(--primary);
  color: #fff;
}
.icon-btn.active, .icon-btn[aria-pressed="true"] {
  background: #0f1b22;            /* pressed/active */
  color: #fff;
  border-color: var(--primary);
}

@media (max-width: 768px) { .container { padding: 12px; } }
/* Header logout and global footer styles */
.logout-form { display: contents; margin: 0; } /* flatten wrapper so button aligns like other pills */
.logout-btn,
.topnav .logout-btn {
  background: transparent;
  border: none;
  color: inherit;
  padding: 0;
  font: inherit;
  cursor: pointer;
}
.logout-btn:hover { color: inherit; text-decoration: none; }

footer {
  background: rgba(23,26,32,.85);
  border-top: 1px solid var(--border);
  margin-top: 24px;
}
.footer {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}
/* Sticky footer: keep footer at bottom on short pages */
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main {
  flex: 1 0 auto;
}
/* Reusable modal primitives (global) */
.modal { position: fixed; inset: 0; display: none; z-index: 110; overflow-y: auto; }
.modal.open { display: block; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); }
.modal-panel {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 3rem auto;
  background: linear-gradient(180deg, var(--bg2), var(--bg3));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-1);
}
.modal-panel-lg { max-width: 800px; }
.modal-header { display:flex; align-items:center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
/* Ensure confirm modal stacks above image editor (ie-modal uses z-index: 9999) */
.modal.modal-confirm { z-index: 10050; }
/* Confirm modal layout helpers (global) */
.modal-form { display: grid; gap: 12px; }
.modal-actions { display: flex; gap: 10px; align-items: center; margin: 8px 0 6px; }

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: linear-gradient(180deg, var(--bg2), var(--bg3));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-1), 0 12px 32px rgba(0,0,0,.4);
  color: var(--fg);
  font-size: 14px;
  max-width: 400px;
  min-width: 280px;
  animation: toast-slide-in 0.3s ease-out;
}

.toast.toast-exiting {
  animation: toast-slide-out 0.25s ease-in forwards;
}

.toast-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 12px;
}

.toast-success .toast-icon {
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
}

.toast-error .toast-icon {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.toast-info .toast-icon {
  background: rgba(17, 179, 213, 0.2);
  color: var(--primary);
}

.toast-success {
  border-color: rgba(34, 197, 94, 0.4);
}

.toast-error {
  border-color: rgba(239, 68, 68, 0.4);
}

.toast-info {
  border-color: rgba(17, 179, 213, 0.4);
}

.toast-content {
  flex: 1;
  line-height: 1.4;
}

.toast-close {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  min-height: auto;
  transition: color 0.15s ease;
}

.toast-close:hover {
  color: var(--fg);
  background: transparent;
}

@keyframes toast-slide-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toast-slide-out {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

@media (max-width: 480px) {
  .toast-container {
    left: 10px;
    right: 10px;
    top: 10px;
  }
  
  .toast {
    min-width: auto;
    max-width: none;
  }
}