/* Modern Web Guidance compliant stylesheet for Dear Me Clinic Admin Dashboard */
:root {
  --bg-page: #faf7f4;
  --bg-card: #ffffff;
  --text-main: #2d1810;
  --text-muted: #6e5a4f;
  --brand-espresso: #3b1d14;
  --brand-sand: #cbb39b;
  --brand-cream: #f5eee8;
  --primary: #c86446;
  --primary-hover: #ae5035;
  --success: #188038;
  --danger: #c5221f;
  --border: #e5d8cd;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
}

.brand-accent-bar {
  height: 5px;
  background: linear-gradient(90deg, #d97757 0%, #cbb39b 52%, #3b1d14 100%);
}

.top-header {
  background: #ffffff;
  color: var(--brand-espresso);
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(59, 29, 20, 0.04);
}

.header-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand-logo-wrap {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.brand-logo {
  display: block;
  height: 46px;
  width: auto;
  object-fit: contain;
}

.brand-divider {
  width: 1px;
  height: 36px;
  background: var(--border);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.brand-badge-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-badge {
  background: #fdf2ee;
  color: var(--primary);
  border: 1px solid #f2cfc2;
  font-weight: 700;
  font-size: 0.72rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  letter-spacing: 0.04em;
}

.brand-rep {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  color: var(--brand-espresso);
  letter-spacing: -0.02em;
}

.domain-bar {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: var(--brand-cream);
  padding: 0.65rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.domain-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.domain-bar label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--brand-espresso);
  margin: 0;
}

.ts-badge {
  background: #dcfce7;
  color: #166534;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
}

.domain-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.domain-bar input {
  width: 310px;
  min-height: 40px;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #cbb39b;
  background: #ffffff;
  color: var(--text-main);
  font-size: 0.9rem;
}

.container {
  max-width: 1240px;
  margin: 1.5rem auto;
  padding: 0 1rem 3rem;
}

.status-banner {
  background: #fdf3ef;
  border: 1px solid #f0c4b4;
  color: var(--brand-espresso);
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius);
  margin-block-end: 1.25rem;
  font-weight: 600;
}

.tab-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-block-end: 1.5rem;
}

.tab-btn {
  font-size: 0.95rem;
  font-weight: 600;
  min-height: 48px;
  padding: 0.65rem 1.2rem;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--brand-espresso);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tab-btn:hover:not(.active) {
  background: var(--brand-cream);
  border-color: var(--brand-sand);
}

.tab-btn.active {
  background: var(--brand-espresso);
  color: #ffffff;
  border-color: var(--brand-espresso);
}

.tab-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 4px 14px rgba(59, 29, 20, 0.04);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  margin-block-end: 1.25rem;
}

.panel-header h2 {
  margin: 0 0 0.25rem;
  font-size: 1.25rem;
  color: var(--brand-espresso);
}

.subtext {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.quick-samples-card {
  background: #fcf9f6;
  border: 1px dashed var(--brand-sand);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-block-end: 1.5rem;
}

.quick-samples-card h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  color: var(--brand-espresso);
}

.sample-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-block-start: 0.75rem;
}

/* Forms & Inputs (modern-web-guidance: forms, validate-input-after-interaction) */
fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-block-end: 1.25rem;
}

legend {
  font-weight: 700;
  padding: 0 0.5rem;
  color: #0f172a;
}

.form-group {
  margin-block-end: 1.1rem;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.form-grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1rem;
}

label,
.group-label {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  margin-block-end: 0.25rem;
}

.hint {
  display: block;
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-block-end: 0.3rem;
}

input[type="text"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="file"],
textarea,
select {
  width: 100%;
  font-size: 1rem;
  padding: 0.65rem 0.8rem;
  min-height: 48px;
  border: 1px solid #94a3b8;
  border-radius: 8px;
  background: #fff;
  color: var(--text-main);
}

@media (pointer: coarse) {
  input[type="text"],
  input[type="tel"],
  input[type="url"],
  input[type="date"],
  button {
    min-height: 52px;
  }
}

input:focus-visible,
button:focus-visible {
  outline: 3px solid #0b57d0;
  outline-offset: 2px;
}

/* Validation states only after user interaction (:user-invalid + fallback) */
.error-msg {
  display: none;
  color: var(--danger);
  font-size: 0.85rem;
  margin-block-start: 0.25rem;
  font-weight: 600;
}

input:user-invalid,
input.user-invalid-fallback {
  border-color: var(--danger);
  background-color: #fce8e6;
}

input:user-invalid + .error-msg,
input.user-invalid-fallback + .error-msg {
  display: block;
}

input:user-valid {
  border-color: var(--success);
}

.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  padding-block-start: 0.25rem;
}

.radio-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
}

.radio-label input[type="radio"] {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.92rem;
  font-weight: 600;
  min-height: 44px;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
}

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

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

.btn-secondary {
  background: var(--brand-cream);
  color: var(--brand-espresso);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: #ece1d6;
}

.btn-outline {
  background: #ffffff;
  border-color: var(--brand-sand);
  color: var(--brand-espresso);
}

.btn-outline:hover {
  background: #fcf8f5;
}

.btn-outline.active-tool {
  background: #fdf2ee;
  border-color: var(--primary);
  color: var(--primary);
}

/* Table */
.table-wrapper {
  overflow-x: auto;
}

.contracts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.contracts-table th,
.contracts-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 0.75rem;
  text-align: left;
  vertical-align: middle;
}

.contracts-table th {
  background: var(--brand-cream);
  font-weight: 700;
  color: var(--brand-espresso);
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

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

.badge-signed {
  background: #dcfce7;
  color: #166534;
}

.action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.btn-seal-manage {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #ffffff;
  border: 1px solid var(--brand-sand);
  color: var(--brand-espresso);
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-seal-manage:hover {
  background: var(--brand-cream);
  border-color: var(--primary);
  color: var(--primary);
}

.header-seal-thumb {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 50%;
  border: 1px solid #f2cfc2;
  background: #fff;
}

/* Seal Management Dialog Styles */
.seal-mgmt-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.5rem;
  margin-block-start: 0.5rem;
}

@media (max-width: 720px) {
  .seal-mgmt-layout {
    grid-template-columns: 1fr;
  }
}

.seal-preview-card {
  background: #fdfaf8;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.seal-preview-card h3 {
  margin: 0 0 0.3rem;
  font-size: 0.98rem;
  color: var(--brand-espresso);
}

.seal-preview-box {
  width: 140px;
  height: 140px;
  border: 2px dashed #e2c0b4;
  border-radius: 12px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0.8rem 0;
  box-shadow: inset 0 0 10px rgba(200, 100, 70, 0.05);
}

.seal-preview-box img {
  max-width: 120px;
  max-height: 120px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(200, 30, 30, 0.25));
}

.seal-preview-box.mini {
  width: 90px;
  height: 90px;
  margin: 0.4rem 0 0.8rem;
}

.seal-preview-box.mini img {
  max-width: 80px;
  max-height: 80px;
}

.seal-options-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}

.seal-tab-buttons {
  display: flex;
  gap: 0.5rem;
  margin-block-end: 1rem;
  border-bottom: 1px solid var(--border);
  padding-block-end: 0.75rem;
}

.seal-tab-buttons .btn {
  font-size: 0.86rem;
}

.seal-tab-buttons .btn.active {
  background: var(--brand-espresso);
  color: #fff;
  border-color: var(--brand-espresso);
}

/* Visual Overlay Seal Box in PDF Editor */
.overlay-box.role-employer {
  border: 2px dashed #dc2626 !important;
  background: rgba(220, 38, 38, 0.08) !important;
  color: #991b1b !important;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: grab;
}

.overlay-box.role-employer:active {
  cursor: grabbing;
}

.overlay-seal-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.overlay-box .overlay-del-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #dc2626;
  color: #fff;
  border: 1px solid #fff;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 11px;
  line-height: 16px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  z-index: 5;
}

/* Native Modal Dialog & Scroll Containment */
dialog:modal {
  overscroll-behavior: contain;
  width: min(960px, 95vw);
  max-height: 90vh;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background: rgba(15, 23, 42, 0.55);
}

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

.modal-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.modal-body {
  padding: 1.25rem 1.5rem;
}

.modal-link-box {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1rem;
  background: #fdf3ef;
  border: 1px solid #f0c4b4;
  border-radius: 8px;
  margin-block-end: 1rem;
}

.modal-link-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.editor-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-block-end: 1rem;
  padding: 0.75rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.tool-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.tool-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.pdf-stage-wrapper {
  display: flex;
  justify-content: center;
  background: #334155;
  padding: 1rem;
  border-radius: 8px;
  overflow: auto;
}

.pdf-stage {
  position: relative;
  width: 612px;
  height: 792px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  user-select: none;
}

.pdf-stage img {
  display: block;
  width: 612px;
  height: 792px;
}

.pdf-overlay-layer {
  position: absolute;
  inset: 0;
}

.overlay-box {
  position: absolute;
  border: 2px solid #16a34a;
  background: rgba(22, 163, 74, 0.16);
  color: #064e3b;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  border-radius: 4px;
}

.overlay-box.role-employer {
  border-color: #dc2626;
  background: rgba(220, 38, 38, 0.16);
  color: #7f1d1d;
}

.overlay-box.role-text {
  border-color: #2563eb;
  background: rgba(37, 99, 235, 0.14);
  color: #1e3a8a;
}

.overlay-del-btn {
  background: #dc2626;
  color: #fff;
  border: none;
  border-radius: 3px;
  width: 16px;
  height: 16px;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.audit-section {
  margin-block-start: 1.25rem;
}

.audit-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 180px;
  overflow-y: auto;
}

.audit-list li {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.85rem;
}
