/**
 * Global app styles: layout, header, buttons, tables, forms.
 * Used by both main app (base.html) and schedule SPA.
 * One global content width for .wrap and #root.
 */

:root {
  --app-content-max-width: 100%;
}

/* --- Layout --- */
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: var(--proplan-font-sans);
  color: var(--proplan-body);
  background: var(--proplan-bg);
}

.wrap {
  max-width: 100%;
  width: 100%;
  margin: 0;
  /* reduce overall vertical padding (approx 70% reduction) */
  padding: 8px 24px;
  box-sizing: border-box;
}

/* --- Header (main app and schedule shell) --- */
.header {
  display: flex;
  flex-direction: row; /* ensure horizontal layout even inside #root > * */
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--proplan-border);
  /* reduce header vertical padding to close the large gap */
  padding: 8px 0;
  margin-bottom: 12px;
  flex: 0 0 auto; /* prevent stretching due to #root > * { flex:1 } */
}

.header h1 {
  margin: 0;
  font-size: 0;
}

.header-logo {
  display: block;
  /* reduce logo height for a tighter header */
  height: 48px;
  width: auto;
  max-width: 360px;
  object-fit: contain;
}

.header a {
  text-decoration: none;
  color: var(--proplan-heading);
}

.header a:hover {
  color: var(--proplan-gold);
}

/* In the Schedule SPA, elements under #root get flex:1 and column layout.
   Ensure the header remains a non-growing horizontal row. */
#root .header {
  flex-direction: row !important;
  flex: 0 0 auto !important;
  /* tighten spacing specifically when header is inside SPA root */
  padding: 6px 0 !important;
}

.header nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.login-logo {
  display: block;
  height: 72px;
  width: auto;
  max-width: 320px;
  margin: 0 auto 1.5rem auto;
  object-fit: contain;
}

/* Schedule SPA: full-screen layout */
.app-shell-wrap {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 24px 24px 12px 24px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  box-sizing: border-box;
}
.app-shell-wrap > .page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.app-shell-wrap .header {
  margin-bottom: 0;
}

#root {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0 24px 24px 24px;
  min-height: 100vh;
  box-sizing: border-box;
}

/* Force schedule SPA pages to use full width of #root (same as .wrap) */
#root .schedule-page,
#root .page.schedule-page,
#root .project-detail {
  max-width: 100%;
  width: 100%;
}

/* --- Page title --- */
.wrap .page-title,
h2.page-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--proplan-heading);
  margin: 0 0 1.25rem 0;
  text-transform: none;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--proplan-border-light);
}

/* --- Flash messages --- */
.flash {
  padding: 10px 14px;
  margin-bottom: 16px;
  border-radius: 4px;
}

.flash.success {
  background: #e8f0e8;
  color: var(--proplan-green);
  border: 1px solid var(--proplan-border-light);
}

.flash.error {
  background: #ffebee;
  color: #c62828;
  border: 1px solid #ef9a9a;
}

.flash.info {
  background: #faf5e6;
  color: #8b6914;
  border: 1px solid var(--proplan-border);
}

/* --- Buttons --- */
.btn {
  display: inline-block;
  padding: 8px 16px;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  border: 0;
  border-radius: 4px;
  font-family: var(--proplan-font-sans);
}

.btn-primary {
  background: var(--proplan-btn-primary-bg);
  color: var(--proplan-btn-primary-text);
}

.btn-primary:hover {
  background: var(--proplan-btn-primary-hover-bg);
  color: var(--proplan-btn-primary-hover-text);
}

.btn-secondary {
  background: var(--proplan-btn-secondary-bg);
  color: var(--proplan-btn-secondary-text);
}

.btn-secondary:hover {
  background: var(--proplan-btn-secondary-hover-bg);
  color: var(--proplan-btn-secondary-hover-text);
}

.btn-danger {
  background: #c62828;
  color: #fff;
}

.btn-danger:hover {
  background: #b71c1c;
  color: #fff;
}

a.btn {
  text-decoration: none;
}

a.btn-primary {
  color: var(--proplan-btn-primary-text);
}

a.btn-primary:hover {
  color: var(--proplan-btn-primary-hover-text);
}

a.btn-secondary {
  color: var(--proplan-btn-secondary-text);
}

a.btn-secondary:hover {
  color: var(--proplan-btn-secondary-hover-text);
}

a.btn-danger {
  color: #fff;
}

a.btn-danger:hover {
  color: #fff;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 13px;
}

/* Schedule SPA: apply same button styles inside #root */
#root .btn,
#root button[type="submit"] {
  display: inline-block;
  padding: 8px 16px;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  border: 0;
  border-radius: 4px;
  font-family: var(--proplan-font-sans);
  background: var(--proplan-btn-primary-bg);
  color: var(--proplan-btn-primary-text);
}

#root .btn:hover,
#root button[type="submit"]:hover {
  background: var(--proplan-btn-primary-hover-bg);
  color: var(--proplan-btn-primary-hover-text);
}

#root .btn-secondary,
#root a.btn-secondary {
  background: var(--proplan-btn-secondary-bg);
  color: var(--proplan-btn-secondary-text);
}

#root .btn-secondary:hover {
  background: var(--proplan-btn-secondary-hover-bg);
  color: var(--proplan-btn-secondary-hover-text);
}

#root .btn-primary,
#root a.btn-primary {
  background: var(--proplan-btn-primary-bg);
  color: var(--proplan-btn-primary-text);
}

#root .btn-danger {
  background: #c62828;
  color: #fff;
}

#root .btn-danger:hover {
  background: #b71c1c;
  color: #fff;
}

#root .btn-sm {
  padding: 4px 10px;
  font-size: 13px;
}

/* --- Forms --- */
form input[type="text"],
form input[type="password"],
form input[type="email"],
form input[type="number"],
form input[type="date"],
form textarea,
form select {
  width: 100%;
  max-width: 320px;
  padding: 8px 10px;
  margin-bottom: 12px;
  box-sizing: border-box;
  border: 1px solid var(--proplan-border-input);
  font-family: var(--proplan-font-sans);
  color: var(--proplan-body);
  background: var(--proplan-bg);
}

form label {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
  color: var(--proplan-heading);
}

.form-actions {
  margin-top: 20px;
}

.form-actions .btn {
  margin-right: 8px;
}

.error-text {
  color: #c62828;
  margin-bottom: 12px;
}

/* Schedule SPA: form controls inside #root */
#root input[type="text"],
#root input[type="password"],
#root input[type="email"],
#root input[type="number"],
#root input[type="date"],
#root textarea,
#root select {
  max-width: 320px;
  padding: 8px 10px;
  margin-bottom: 12px;
  border: 1px solid var(--proplan-border-input);
  font-family: var(--proplan-font-sans);
  color: var(--proplan-body);
  background: var(--proplan-bg);
}

#root label {
  font-weight: 600;
  color: var(--proplan-heading);
}

/* --- Tables --- */
table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--proplan-border-light);
}

th {
  font-weight: 600;
  color: var(--proplan-heading);
  background: var(--proplan-bg-off);
}

/* Schedule SPA: tables inside #root same width and style */
#root table {
  width: 100%;
  border-collapse: collapse;
}

#root th,
#root td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--proplan-border-light);
}

#root th {
  font-weight: 600;
  color: var(--proplan-heading);
  background: var(--proplan-bg-off);
}

.actions {
  white-space: nowrap;
}

/* Ensure spacing between action buttons in lists */
.actions > .btn,
.actions > button,
.actions > a.btn { margin-right: 8px; }
.actions > .btn:last-child,
.actions > button:last-child,
.actions > a.btn:last-child { margin-right: 0; }

.actions a,
.actions button {
  margin-right: 8px;
}
