/* SendMate — SaaS UI */

:root {
  --sidebar-width: 220px;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-hover: #1e293b;
  --sidebar-active: #3b82f6;
  --accent: #3b82f6;
  --flash-bg: #ecfdf5;
  --flash-border: #a7f3d0;
  --flash-error-bg: #fef2f2;
  --flash-error-border: #fecaca;
}

html { font-size: 16px; }
body { line-height: 1.55; }
h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 0; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: 1.05rem; font-weight: 600; }

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

/* Sidebar */
nav.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
  border-right: 1px solid #1e293b;
}

nav.sidebar header h2 {
  margin: 0 0 1.75rem 0.5rem;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

nav.sidebar header h2 a {
  color: #f1f5f9;
  text-decoration: none;
}

nav.sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
  flex: 1;
  display: flex !important;
  flex-direction: column !important;
  flex-wrap: nowrap !important;
  gap: 2px;
}

nav.sidebar ul li { width: 100%; }

nav.sidebar ul li a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.7rem;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s;
}

nav.sidebar ul li a [class^="icon-"],
nav.sidebar footer a [class^="icon-"] {
  font-size: 1.1rem;
  width: 1.3rem;
  text-align: center;
  flex-shrink: 0;
}

nav.sidebar ul li a:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
}

nav.sidebar ul li a.active {
  background: rgba(59,130,246,0.15);
  color: var(--sidebar-active);
}

nav.sidebar footer {
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid #1e293b;
}

nav.sidebar footer a {
  font-size: 0.82rem;
  padding: 0.35rem 0.6rem;
  color: var(--sidebar-text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 6px;
  transition: all 0.15s;
}

nav.sidebar footer a:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
}

/* Content */
.content {
  margin-left: var(--sidebar-width);
  padding: 1.75rem 2.25rem;
  flex: 1;
  min-width: 0;
  max-width: 1300px;
}

/* Login */
.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-page article {
  max-width: 380px;
  width: 100%;
}

/* Lists Grid (campaign form) */
.lists-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.4rem;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 8px;
  padding: 0.5rem;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  margin: 0;
  transition: background 0.1s;
}

.list-item:hover {
  background: var(--pico-muted-border-color);
}

.list-item input[type="checkbox"] {
  margin: 0;
  flex-shrink: 0;
}

.list-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item-count {
  font-size: 0.72rem;
  color: var(--pico-muted-color);
  flex-shrink: 0;
  background: var(--pico-muted-border-color);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
}

/* Flash */
.flash-message {
  padding: 0.6rem 0.9rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.88rem;
  background: var(--flash-bg);
  border: 1px solid var(--flash-border);
  color: #065f46;
}

.flash-message.error {
  background: var(--flash-error-bg);
  border-color: var(--flash-error-border);
  color: #991b1b;
}

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  padding: 1rem 1.15rem;
  border-radius: 10px;
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-muted-border-color);
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}

.stat-card .stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--pico-muted-color);
  margin: 0.15rem 0 0 0;
  font-weight: 500;
}

/* Tables */
table { font-size: 0.9rem; }

table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 600;
  color: var(--pico-muted-color);
  padding: 0.6rem 0.85rem;
  border-bottom-width: 2px;
}

table td {
  padding: 0.55rem 0.85rem;
  vertical-align: middle;
}

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

.actions a, .actions button {
  font-size: 0.78rem;
  padding: 0.25rem 0.55rem;
  margin: 0;
  border-radius: 4px;
}

/* Badge */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-active { background: #dcfce7; color: #166534; }
.badge-bounced { background: #fee2e2; color: #991b1b; }
.badge-unsubscribed { background: #fef9c3; color: #854d0e; }
.badge-draft { background: #f1f5f9; color: #475569; }
.badge-sending { background: #dbeafe; color: #1e40af; }
.badge-sent { background: #dcfce7; color: #166534; }
.badge-paused { background: #fef9c3; color: #854d0e; }
.badge-failed { background: #fee2e2; color: #991b1b; }
.badge-queued { background: #f1f5f9; color: #475569; }

/* Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.page-header h1 { margin: 0; }

.page-header h1 small {
  font-size: 0.85rem;
  color: var(--pico-muted-color);
  font-weight: 400;
}

.page-header a[role="button"], .page-header button {
  font-size: 0.85rem;
  padding: 0.45rem 1rem;
}

/* Forms */
label {
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

article {
  padding: 1.15rem 1.25rem;
  margin-bottom: 1rem;
  border-radius: 10px;
}

article header { margin-bottom: 0.65rem; }
article header h3 { margin: 0; }
details summary { font-size: 0.9rem; font-weight: 500; }

/* MJML Editor */
.editor-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  height: 72vh;
}

.editor-layout textarea {
  height: 100%;
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
  font-size: 0.82rem;
  resize: none;
  border-radius: 8px;
}

.editor-layout iframe,
#preview-output {
  width: 100%;
  height: 100%;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 8px;
  background: #fff;
}

/* Campaign Progress */
.progress-bar {
  width: 100%;
  height: 0.5rem;
  border-radius: 4px;
  overflow: hidden;
  background: #e2e8f0;
  margin-bottom: 0.4rem;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s;
}

/* Import */
.import-stats {
  display: flex;
  gap: 1.25rem;
  margin: 0.65rem 0;
  font-size: 0.88rem;
}

.import-stats span { font-weight: 600; }

/* Image Gallery */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.image-card {
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 8px;
  overflow: hidden;
}

.image-card img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
}

.image-info {
  padding: 0.5rem;
}

.image-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.75rem;
  margin-bottom: 0.25rem;
}

.badge-scheduled { background: #fef3c7; color: #92400e; }

/* Toast */
.toast {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 1000;
}

.toast-item {
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  font-size: 0.85rem;
  background: var(--sidebar-bg);
  color: #f1f5f9;
  margin-top: 0.5rem;
  animation: fadeIn 0.2s ease-out;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

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

/* Responsive */
@media (max-width: 768px) {
  .app-layout { flex-direction: column; }
  nav.sidebar {
    position: relative;
    width: 100%;
    min-width: 100%;
    flex-direction: row;
    padding: 0.5rem 0.75rem;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid #1e293b;
  }
  nav.sidebar ul { flex-direction: row !important; gap: 0.25rem; overflow-x: auto; }
  nav.sidebar ul li a [class^="icon-"] { display: none; }
  nav.sidebar footer { margin-top: 0; border: none; }
  .content { margin-left: 0; padding: 1rem; }
  .editor-layout { grid-template-columns: 1fr; height: auto; }
}
