/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Figtree', 'Segoe UI', sans-serif; color: #1a1a1a; background: #f5f5f0; min-height: 100vh; }
a { color: #4a6b0a; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ── */
.pa-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 56px; background: #fff;
  border-bottom: 1px solid #e0e0d8; position: sticky; top: 0; z-index: 100;
}
.pa-header-logo {
  display: flex; align-items: center; gap: 10px;
}
.pa-header-logo img { height: 28px; }
.pa-header-logo span {
  font-size: 16px; font-weight: 600; color: #243001; letter-spacing: 0.5px;
}
.pa-header-nav { display: flex; align-items: center; gap: 8px; }
.pa-header-nav a, .pa-header-nav button {
  font-family: 'Figtree', sans-serif; font-size: 13px; font-weight: 500;
  padding: 6px 14px; border-radius: 6px; border: none; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.pa-header-nav a { color: #243001; background: transparent; }
.pa-header-nav a:hover { background: #f0f0e8; text-decoration: none; }
.pa-btn-primary {
  background: #243001 !important; color: #fff !important;
  font-family: 'Figtree', sans-serif; font-size: 13px; font-weight: 600;
  padding: 7px 16px; border-radius: 6px; border: none; cursor: pointer;
}
.pa-btn-primary:hover { background: #344a08 !important; }
.pa-btn-outline {
  background: transparent; color: #243001; border: 1.5px solid #c8c8b8;
  font-family: 'Figtree', sans-serif; font-size: 13px; font-weight: 500;
  padding: 6px 14px; border-radius: 6px; cursor: pointer;
}
.pa-btn-outline:hover { border-color: #243001; background: #fafaf5; }
.pa-user-badge {
  font-size: 12px; color: #666; padding: 4px 10px;
  background: #f0f0e8; border-radius: 12px;
}

/* ── Auth Modal ── */
.pa-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.pa-modal-overlay.active { opacity: 1; pointer-events: auto; }
.pa-modal {
  background: #fff; border-radius: 12px; padding: 32px; width: 400px;
  max-width: 90vw; box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.pa-modal h2 {
  font-size: 20px; font-weight: 700; color: #243001; margin-bottom: 4px;
}
.pa-modal p.subtitle { font-size: 13px; color: #888; margin-bottom: 20px; }
.pa-form-group { margin-bottom: 14px; }
.pa-form-group label {
  display: block; font-size: 12px; font-weight: 600; color: #555;
  margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.5px;
}
.pa-form-group input {
  width: 100%; padding: 10px 12px; border: 1.5px solid #d8d8d0;
  border-radius: 6px; font-size: 16px; font-family: 'Figtree', sans-serif;
  outline: none; transition: border-color 0.15s;
  -webkit-appearance: none; appearance: none;
}
.pa-form-group input:focus { border-color: #4a6b0a; }
.pa-form-error {
  color: #c0392b; font-size: 12px; margin-top: 4px; min-height: 16px;
}
.pa-modal-footer {
  margin-top: 16px; text-align: center; font-size: 13px; color: #888;
}
.pa-modal-footer a { font-weight: 600; }
.pa-modal .pa-btn-primary { width: 100%; padding: 11px; font-size: 14px; margin-top: 6px; }
.pa-modal-close {
  position: absolute; top: 12px; right: 14px; background: none; border: none;
  font-size: 22px; color: #aaa; cursor: pointer; line-height: 1;
}

/* ── Dashboard ── */
.pa-dashboard { max-width: 960px; margin: 0 auto; padding: 32px 24px; }
.pa-dashboard-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px;
}
.pa-dashboard-header h1 { font-size: 22px; font-weight: 700; color: #243001; }
.pa-project-grid { display: flex; flex-direction: column; gap: 8px; }
.pa-project-card {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; background: #fff; border-radius: 8px;
  border: 1px solid #e8e8e0; transition: border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
}
.pa-project-card:hover {
  border-color: #b8c890; box-shadow: 0 2px 8px rgba(36,48,1,0.06);
}
.pa-project-info { flex: 1; min-width: 0; }
.pa-project-name {
  font-size: 15px; font-weight: 600; color: #1a1a1a;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pa-project-meta {
  font-size: 12px; color: #888; margin-top: 3px;
  display: flex; gap: 16px; flex-wrap: wrap;
}
.pa-project-actions { display: flex; gap: 6px; opacity: 0; transition: opacity 0.15s; }
.pa-project-card:hover .pa-project-actions { opacity: 1; }
.pa-project-actions button {
  font-family: 'Figtree', sans-serif; font-size: 11px; font-weight: 500;
  padding: 5px 10px; border-radius: 4px; border: 1px solid #d8d8d0;
  background: #fff; color: #555; cursor: pointer;
}
.pa-project-actions button:hover { background: #f5f5f0; color: #243001; }
.pa-project-actions button.danger:hover { background: #fdf0f0; color: #c0392b; border-color: #e0b0b0; }
.pa-empty-state {
  text-align: center; padding: 60px 20px; color: #aaa;
}
.pa-empty-state h3 { font-size: 16px; color: #888; margin-bottom: 8px; }

/* ── Shared View ── */
.pa-shared-banner {
  background: #243001; color: #fff; text-align: center; padding: 8px;
  font-size: 12px; font-weight: 500; letter-spacing: 0.3px;
}
.pa-shared-banner span { opacity: 0.7; }
.pa-shared-badge {
  display: inline-block; background: rgba(255,255,255,0.15);
  padding: 2px 8px; border-radius: 3px; margin-left: 8px; font-size: 11px;
}
.pa-shared-content {
  max-width: 960px; margin: 0 auto; padding: 32px 24px;
}
.pa-shared-title {
  font-size: 20px; font-weight: 700; color: #243001; margin-bottom: 4px;
}
.pa-shared-subtitle { font-size: 13px; color: #888; margin-bottom: 24px; }
.pa-spec-table {
  width: 100%; border-collapse: collapse; background: #fff;
  border-radius: 8px; overflow: hidden; border: 1px solid #e8e8e0;
}
.pa-spec-table th {
  text-align: left; padding: 10px 16px; background: #f8f8f4;
  font-size: 11px; font-weight: 600; color: #666;
  text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 1px solid #e8e8e0;
}
.pa-spec-table td {
  padding: 10px 16px; font-size: 13px; border-bottom: 1px solid #f0f0ea;
}
.pa-spec-table tr:last-child td { border-bottom: none; }
.pa-bom-section { margin-top: 24px; }
.pa-bom-section h3 {
  font-size: 14px; font-weight: 600; color: #243001; margin-bottom: 12px;
}

/* ── Dropdown ── */
.pa-dropdown { position: relative; display: inline-block; }
.pa-dropdown-menu {
  position: absolute; top: 100%; right: 0; margin-top: 4px;
  background: #243001; border-radius: 6px; padding: 4px 0;
  min-width: 160px; box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  z-index: 200; display: none;
}
.pa-dropdown.open .pa-dropdown-menu { display: block; }
.pa-dropdown-menu a, .pa-dropdown-menu button {
  display: block; width: 100%; padding: 8px 14px; border: none;
  background: none; color: #fff; font-family: 'Figtree', sans-serif;
  font-size: 13px; text-align: left; cursor: pointer;
}
.pa-dropdown-menu a:hover, .pa-dropdown-menu button:hover {
  background: rgba(255,255,255,0.1); text-decoration: none;
}
.pa-dropdown-divider { border-top: 1px solid rgba(255,255,255,0.1); margin: 4px 0; }

/* ── Toast ── */
.pa-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: #243001; color: #fff; padding: 10px 20px; border-radius: 8px;
  font-size: 13px; font-weight: 500; box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  transition: transform 0.3s ease; z-index: 2000; pointer-events: none;
  max-width: calc(100vw - 32px); text-align: center;
}
.pa-toast.show { transform: translateX(-50%) translateY(0); }

/* ── Footer ── */
.pa-footer {
  text-align: center; padding: 24px 16px; font-size: 11px; color: #aaa;
  border-top: 1px solid #e8e8e0; margin-top: 40px;
  word-wrap: break-word; overflow-wrap: break-word;
}

/* ── Loading ── */
.pa-loading { text-align: center; padding: 40px; color: #aaa; }
.pa-spinner {
  display: inline-block; width: 24px; height: 24px;
  border: 2.5px solid #e0e0d8; border-top-color: #4a6b0a;
  border-radius: 50%; animation: pa-spin 0.6s linear infinite;
}
@keyframes pa-spin { to { transform: rotate(360deg); } }


/* ═══════════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — overrides React inline styles
   ═══════════════════════════════════════════════════════════════════ */

/* ── Tablet (max 900px) ── */
@media (max-width: 900px) {

  /* Auth buttons beside hamburger — shrink to fit */
  #pa-header-nav {
    gap: 4px !important;
  }
  #pa-header-nav .pa-btn-primary,
  #pa-header-nav .pa-btn-outline,
  #pa-header-nav button,
  #pa-header-nav a {
    font-size: 11px !important;
    padding: 5px 10px !important;
  }
  #pa-header-nav .pa-user-badge {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Toolbar — wrap items */
  #pa-toolbar {
    flex-wrap: wrap !important;
    gap: 6px !important;
    padding: 8px 14px !important;
  }
  #pa-toolbar > div {
    flex-wrap: wrap !important;
  }
  #pa-toolbar input[type="text"] {
    font-size: 16px !important;
    min-width: 0 !important;
    width: auto !important;
    flex: 1 1 120px !important;
  }

  /* Form grids inside .no-print — collapse to 2 columns max */
  .no-print div[style*="grid-template-columns"] {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Modal */
  .pa-modal {
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Dashboard */
  .pa-dashboard { padding: 20px 14px; }
  .pa-dashboard-header { flex-wrap: wrap; gap: 10px; }

  .pa-project-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
  }
  .pa-project-actions {
    opacity: 1;
    width: 100%;
    flex-wrap: wrap;
  }
  .pa-project-actions button {
    flex: 1 1 auto;
    text-align: center;
    padding: 8px 10px;
    min-height: 36px;
  }

  /* Shared view */
  .pa-shared-content { padding: 20px 14px; }
  .pa-shared-banner { font-size: 11px; }

  /* Scrollable spec tables */
  .pa-spec-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .pa-bom-section { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Toast */
  .pa-toast { bottom: 16px; font-size: 12px; padding: 10px 16px; }
}


/* ── Phone (max 600px) ── */
@media (max-width: 600px) {

  /* All form grids go single column */
  .no-print div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }

  /* Form inputs — prevent iOS zoom (min 16px) */
  .no-print input, .no-print select, .no-print textarea {
    font-size: 16px !important;
  }

  /* Footer grid — stack to 1 column */
  /* Footer is the last .no-print div with background #243001 */
  #root div[style*="grid-template-columns"]:last-of-type {
    grid-template-columns: 1fr !important;
  }

  /* Auth buttons — even smaller */
  #pa-header-nav {
    gap: 3px !important;
  }
  #pa-header-nav .pa-btn-primary,
  #pa-header-nav .pa-btn-outline,
  #pa-header-nav button,
  #pa-header-nav a {
    font-size: 10px !important;
    padding: 4px 8px !important;
  }
  #pa-header-nav .pa-user-badge { display: none !important; }
  #pa-header-nav .pa-dropdown .pa-btn-outline {
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Toolbar — fully stack */
  #pa-toolbar {
    padding: 8px 10px !important;
  }
  #pa-toolbar > div {
    width: 100% !important;
  }
  #pa-toolbar input[type="text"] {
    width: 100% !important;
    flex: 1 1 100% !important;
  }
  #pa-toolbar button, #pa-toolbar a {
    flex: 1 1 auto;
    text-align: center;
    min-height: 36px;
  }

  /* Form card padding */
  .no-print div[style*="padding: 14px"],
  .no-print div[style*="padding:14px"] {
    padding: 10px !important;
  }

  /* Modal */
  .pa-modal { padding: 20px 16px; border-radius: 10px; }

  /* Dashboard */
  .pa-dashboard { padding: 16px 10px; }
  .pa-dashboard-header h1 { font-size: 17px; }
  .pa-project-card { padding: 12px; }
  .pa-project-name { font-size: 14px; }
  .pa-project-actions button { font-size: 11px; }

  /* Shared view */
  .pa-shared-content { padding: 16px 10px; }
  .pa-shared-title { font-size: 17px; }
  .pa-spec-table th, .pa-spec-table td {
    padding: 8px 10px; font-size: 12px;
  }

  /* Empty state */
  .pa-empty-state { padding: 40px 16px; }
}


/* ── Very small phones (max 380px) ── */
@media (max-width: 380px) {

  /* Hide auth link text on tiny screens, keep hamburger */
  #pa-header-nav a[href="/dashboard"] { display: none !important; }

  .pa-btn-primary { font-size: 11px !important; padding: 5px 10px !important; }
  .pa-btn-outline { font-size: 11px; padding: 5px 8px; }

  .pa-modal h2 { font-size: 17px; }
  .pa-modal-close { font-size: 26px; padding: 6px 10px; }

  .pa-dashboard-header h1 { font-size: 15px; }
}
