/* public/core.css */

/* 1. Import Inter Font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ---------- Theme tokens (Modern Light) ---------- */
:root {
  /* Layout Colors */
  --bg: #f3f4f6;          /* Light Gray Body */
  --panel: #ffffff;       /* White Cards */
  --panel-hover: #f9fafb; /* Light hover state */
  
  /* Borders */
  --border: #e5e7eb;
  --border-focus: #2563eb; /* Blue focus */

  /* Text Colors */
  --text: #1f2937;        /* Dark Gray (almost black) */
  --text-muted: #6b7280;  /* Medium Gray */
  
  /* Brand/Action Colors */
  --brand: #2563eb;       /* Primary Blue */
  --brand-hover: #1d4ed8;
  --danger: #ef4444;
  --success: #10b981;

  /* Spacing & Radius */
  --r-lg: 12px;           /* Card Radius */
  --r-md: 8px;            /* Button/Input Radius */
  --pad: 24px;            /* Card Padding */
  --gap: 16px;

  /* Modern Shadow */
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* ---------- Reset / base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a { color: var(--brand); text-decoration: none; font-weight: 500; transition: color 0.2s; }
a:hover { color: var(--brand-hover); text-decoration: underline; }

/* Code blocks */
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background: #f1f5f9;
  border: 1px solid var(--border);
  color: #0f172a;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.9em;
}

h1, h2, h3 { 
  margin-top: 0; 
  color: #111827; 
  letter-spacing: -0.025em; 
}
h2 { font-size: 1.5rem; font-weight: 700; }

/* ---------- Layout helpers ---------- */
.wrap { max-width: 1200px; margin: 0 auto; padding: 2rem; }
.wrap.narrow { max-width: 980px; }
.wrap.tiny { max-width: 520px; }

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--gap);
  flex-wrap: wrap;
}

/* Helper for "Space Between" rows */
.rowBetween {
  display: flex;
  justify-content: space-between;
  align-items: flex-end; /* Align bottom for inputs/labels */
  margin-bottom: 1.5rem;
  width: 100%;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--gap);
  margin-bottom: 24px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--pad);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.cardTitle {
  font-size: 1.125rem;
  font-weight: 600;
  color: #111827;
  margin-bottom: 0.75rem;
  display: block;
}

/* ---------- Grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--gap);
  margin-top: 16px;
}

/* ---------- Typography bits ---------- */
.muted { color: var(--text-muted); font-size: 0.875rem; }

/* Messages / Alerts */
.msg { 
  padding: 12px 16px; 
  border-radius: var(--r-md); 
  margin-bottom: 20px; 
  font-weight: 500; 
  font-size: 0.9rem;
}
.msg.ok { background-color: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.msg.err { background-color: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: var(--r-md);
  transition: all 0.2s ease;
  border: 1px solid var(--border);
  background-color: white;
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  gap: 8px;
}

.btn:hover {
  background-color: #f9fafb;
  border-color: #d1d5db;
  text-decoration: none;
}

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

/* AUTO-MAGIC: If a button links to "new", make it Blue (Primary) */
a.btn[href*="new"], .btn.primary {
  background-color: var(--brand);
  color: white;
  border-color: var(--brand);
}
a.btn[href*="new"]:hover, .btn.primary:hover {
  background-color: var(--brand-hover);
  border-color: var(--brand-hover);
  color: white;
}

.smallbtn {
  padding: 6px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  cursor: pointer;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.smallbtn:hover { background: #f3f4f6; }

.btn.full { width: 100%; }

/* ---------- Inputs ---------- */
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input::placeholder, textarea::placeholder { color: #9ca3af; }

input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

textarea {
  min-height: 150px; /* Reduced from 520px to be more standard, change back if needed */
  line-height: 1.5;
}

label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  display: block;
  margin-bottom: 6px;
}

/* Custom Select Dropdown Arrow */
select.btnSelect {
  appearance: none;
  padding-right: 2.5rem;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
}

/* ---------- Tables ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin-top: 12px;
}

th {
  background-color: #f9fafb;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tbody tr:hover { background-color: #f9fafb; }

/* ---------- Profile / Topbar Specifics ---------- */
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 2rem; }
.topbar h2 { margin: 0 0 0.5rem 0; }
.topbar .left { display: flex; flex-direction: column; }

/* Profile Dropdown */
.profileWrap { position: relative; }
.profileBtn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s;
}
.profileBtn:hover { background: #f9fafb; }

.profileName { font-weight: 500; font-size: 0.9rem; }
.profileAvatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  object-fit: cover;
}

.profileMenu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 180px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 6px;
  display: none;
  z-index: 50;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}
.profileWrap.open .profileMenu { display: block; }

.menuBtn {
  width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-size: 0.9rem;
  transition: background 0.1s;
}
.menuBtn:hover { background: #f3f4f6; }

/* ---------- Modern Modal System ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: none; /* Hidden by default */
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

.modal-overlay.active { display: flex; animation: fadeIn 0.2s ease; }

.modal-card {
  background: white;
  width: 100%;
  max-width: 400px;
  border-radius: 16px;
  padding: 32px;
  text-align: center;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal-card { transform: translateY(0); }

/* Icons */
.modal-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.icon-success { background: #d1fae5; color: #10b981; }
.icon-error { background: #fee2e2; color: #ef4444; }

.modal-title { font-size: 1.25rem; font-weight: 700; color: #111827; margin-bottom: 8px; }
.modal-text { color: #6b7280; font-size: 0.95rem; margin-bottom: 24px; line-height: 1.5; }

.modal-footer { display: flex; gap: 12px; justify-content: center; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Utilities ---------- */
.col { flex: 1; min-width: 220px; }
.checkrow { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.checkrow label { margin: 0; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.checkrow input[type="checkbox"] { width: auto; margin: 0; }

.hidden { display: none !important; }

/* Spacing Helpers */
.mt6, .mt-6 { margin-top: 0.5rem; }
.mt10, .mt-10 { margin-top: 0.75rem; }
.mt12, .mt-12 { margin-top: 1rem; }
.mt14, .mt-14 { margin-top: 1.25rem; }