/* Root theme variables */
:root {
  --bg-main: #f8fafc;
  --bg-matrix: #f8fafc;
  --bg-column: #e1f3ff;
  --bg-card: #fff;
  --text-main: #222;
  --text-secondary: #444;
  --btn-gradient: linear-gradient(90deg, #009ddc 60%, #5bc0de 100%);
  --btn-gradient-hover: linear-gradient(90deg, #007bb8 60%, #009ddc 100%);
}

body.dark-mode {
  --bg-main: #181c23;
  --bg-matrix: #181c23;
  --bg-column: #232f3e;
  --bg-card: #60708f;
  --text-main: #f3f6fa;
  --text-secondary: #b0b8c1;
  --btn-gradient: linear-gradient(90deg, #1e90ff 60%, #009ddc 100%);
  --btn-gradient-hover: linear-gradient(90deg, #007bb8 60%, #1e90ff 100%);
}

/* General body and container styles */
body, .main-container {
  background: var(--bg-main) !important;
  color: var(--text-main) !important;
  margin: 0;
  font-family: sans-serif;
}
.main-container {
  margin: 10px;
  padding: 5px;
  background: #f8fafc;
  border-radius: 18px;
}

/* Matrix and columns */
.matrix {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: center;
  overflow-x: auto;
  min-height: 400px;
  background: var(--bg-matrix);
}
.column {
  flex: 0 0 250px;
  background: var(--bg-column);
  border-radius: 10px;
  margin: 0 10px;
  padding: 10px;
  color: var(--text-main);
}
.column h3 {
  text-align: center;
}

/* Cards */
.card {
  background: var(--bg-card);
  color: var(--text-main);
  border-radius: 6px;
  padding: 8px;
  margin: 8px 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    position: relative;
  z-index: 10;
}
.card button {
  margin: 4px 2px 0 0;
  padding: 4px 6px;
  font-size: 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
.card .connect-btn { background: #ff8c00; color: white; }
.card .delete-btn { background: #d9534f; color: white; }
.card .expand-btn { background: #5bc0de; color: white; }
.leader-line {
  z-index: 1 !important;
}
/* Add card/column buttons */
.add-card-btn, #add-column-btn {
  width: 100%;
  padding: 5px;
  background: #009ddc;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 5px;
}

/* Modal and overlay */
.modal, .field-modal {
  position: fixed;
  top: 6%;
  left: 50%;
  transform: translate(-50%, 0);
  background: rgba(60, 70, 100, 0.95);
  color: var(--text-main);
  padding: 0;
  z-index: 1000;
  border-radius: 18px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  width: 900px;
  max-width: 120vw;
  max-height: 100vh;
  display: none;
  overflow: hidden;
  border: 1.5px solid #5bc0de;
  backdrop-filter: blur(6px);
  animation: modalPopIn 0.18s cubic-bezier(.4,2,.6,1) 1;
}
@keyframes modalPopIn {
  0% { transform: translate(-50%, -30px) scale(0.98);}
  100% { transform: translate(-50%, 0) scale(1);}
}
.overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.3);
  z-index: 999;
  display: none;
}

/* Modal header */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(90deg, #009ddc 60%, #5bc0de 100%);
  color: #fff;
  padding: 18px 28px 14px 18px;
  border-radius: 18px 18px 0 0;
  position: sticky;
  top: 0;
  z-index: 2;
}
.modal-header .modal-title {
  flex: 1;
  text-align: center;
  font-size: 1.7em;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin: 0 18px;
}
.modal-header .modal-exit-btn,
.modal-header .modal-save-btn {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 0.98em;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 12px;
  border-radius: 6px;
  transition: background 0.15s;
  white-space: nowrap;
}
.modal-header .modal-save-btn {
  background: #5bc0de;
  font-size: 0.95em;
  font-weight: 600;
  padding: 4px 16px;
  margin-left: 18px;
  transition: background 0.15s;
}
.modal-header .modal-exit-btn:hover,
.modal-header .modal-save-btn:hover {
  background: rgba(255,255,255,0.12);
}
.modal-header .modal-save-btn:hover {
  background: #009ddc;
}

/* Modal content scrollable */
.modal-content {
  padding: 0 0 0 0;
  overflow-y: auto;
  max-height: 62vh;
}

/* Modal form fields */
.modal input, .modal textarea {
  width: 100%;
  margin-bottom: 12px;
  background: var(--bg-main);
  color: var(--text-main);
  border: 1.5px solid #5bc0de;
  border-radius: 7px;
  padding: 10px 0 10px;
  font-size: 1.1em;
  transition: border 0.2s;
}
.modal input:focus, .modal textarea:focus {
  border: 1.5px solid #009ddc;
  outline: none;
  background: #373838;
}
.modal label {
  color: var(--text-main);
  font-weight: 600;
  margin-bottom: 2px;
  margin-top: 8px;
  letter-spacing: 0.2px;
}

/* Modal tab bar */
.modal-tab-bar {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
  padding: 0;           /* Remove left/right padding */
}


/* Tabs */
.tabs, .modal-tab-bar {
  display: flex;
  margin-bottom: 10px;
}
.tab {
  flex: 1;
  text-align: center;
  padding: 5px;
  cursor: pointer;
  background: #ccc;
}
.tab.active {
  background: #aaa;
  font-weight: bold;
}
.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}

/* Summary tab form */
#summary-tab form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 10px;
}
#summary-tab label {
  font-weight: 500;
  margin-bottom: 2px;
}
#summary-tab input {
  padding: 8px;
  border: 1px solid #bbb;
  border-radius: 6px;
  background: #f8fafc;
  font-size: 15px;
  transition: border 0.2s;
}
#summary-tab input:focus {
  border: 1.5px solid #009ddc;
  outline: none;
}

/* Save card button */
#save-card {
  width: 100%;
  margin-top: 18px;
  padding: 12px 0;
  background: var(--btn-gradient);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1.15em;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  transition: background 0.2s;
}
#save-card:hover {
  background: var(--btn-gradient-hover);
}

/* Connections tab two-column layout */
#connections-tab > div {
  display: flex;
  gap: 24px;
  margin-top: 10px;
}
#connections-tab > div > div {
  flex: 1;
  background: #f8fafc;
  border-radius: 8px;
  padding: 10px;
  min-width: 0;
  box-sizing: border-box;
}
#connections-tab strong {
  display: block;
  margin-bottom: 8px;
  font-size: 15px;
}
#connections-tab button {
  margin-left: 10px;
}

/* Manila folder effect for matrix and filename */
.folder-container {
  border: 3px solid #009ddc;
  border-radius: 0 16px 12px 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  padding: 16px 16px 60px 16px;
  width: 100%;
  margin: 0;
  position: relative;
  box-sizing: border-box;
}
.folder-tab {
  display: inline-block;
  position: absolute;
  top: -3px;
  left: 40px;
  border: 3px solid #009ddc;
  border-bottom: none;
  border-top: none;
  border-radius: 16px 16px 0 0;
  padding: 12px 48px 10px 48px;
  font-size: 1.5em;
  font-weight: bold;
  color: #009ddc;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.04);
  cursor: pointer;
  z-index: 2;
  text-align: center;
  min-width: 220px;
  letter-spacing: 0.5px;
  transition: background 0.2s, color 0.2s;
  user-select: none;
  background: var(--bg-main);
}
.folder-tab:hover {
  background: #e1f3ff;
  color: #007bb8;
}

/* Toggle Switch Styles */
.switch {
  position: relative;
  display: inline-block;
  width: 56px;
  height: 32px;
  z-index: 10;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(90deg, #bde6fa 60%, #fdf6e3 100%);
  border-radius: 32px;
  transition: background 0.3s;
}
.slider:before {
  position: absolute;
  content: "";
  height: 24px;
  width: 24px;
  left: 4px;
  bottom: 4px;
  background: radial-gradient(circle at 30% 30%, #ffe066 80%, #ffe066 100%);
  border-radius: 50%;
  transition: transform 0.3s, background 0.3s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}
.switch input:checked + .slider {
  background: linear-gradient(90deg, #22314a 60%, #162032 100%);
}
.switch input:checked + .slider:before {
  transform: translateX(24px);
  background: radial-gradient(circle at 70% 70%, #cfd8dc 80%, #b0bec5 100%);
}

/* Titles and filename */
.main-title {
  text-align: center;
  font-size: 2.2em;
  font-weight: 800;
  margin: 16px 0 6px 0;
  color: #009ddc;
  letter-spacing: 1.5px;
  text-shadow: 0 2px 8px rgba(0,157,220,0.08);
}
body.dark-mode .main-title {
  color: #5bc0de;
  text-shadow: 0 2px 8px rgba(0,157,220,0.18);
}
#matrix-filename {
  display: block;
  width: 100%;
  text-align: center;
  font-size: 1.7em;
  font-weight: 700;
  color: #009ddc;
  margin: 18px 0 24px 30px;
  letter-spacing: 0.5px;
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.2s;
}
body.dark-mode #matrix-filename {
  color: #5bc0de;
}
#matrix-filename:hover {
  color: #007bb8;
}

.line-delete-btn {
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

#matrix-title {
  display: inline-block;
  width: 100%;
  text-align: center;
  font-size: 1.5em;
  font-weight: 700;
  color: #009ddc;
  margin: 10px 0 15px 0;
  letter-spacing: 1px;
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.2s;
  z-index: 10;
  position: relative;
}
body.dark-mode #matrix-title {
  color: #5bc0de;
}
#matrix-title:hover {
  color: #007bb8;
}
#matrix-title-text {
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
  transition: background 0.15s;
  display: inline-block;
}
#matrix-title-text:hover {
  background: #e1f3ff;
}

/* Column settings modal */
#col-settings-modal {
  background: #232946;
  color: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  padding: 24px 28px 18px 28px;
  min-width: 320px;
  max-width: 95vw;
  width: 370px;
  font-family: inherit;
  border: 2px solid #5bc0de;
  position: fixed;
  top: 12vh;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2001;
  display: block;
}

#col-settings-modal h3 {
  margin-top: 0;
  margin-bottom: 18px;
  font-size: 1.2em;
  color: #ffe066;
  text-align: center;
  letter-spacing: 0.5px;
}

#col-settings-form > div {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

#col-settings-form input {
  flex: 1;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid #444;
  background: #16161a;
  color: #fff;
  font-size: 1em;
  transition: border 0.2s;
}
#col-settings-form input:focus {
  border: 1.5px solid #5bc0de;
  outline: none;
}

#col-settings-form button {
  background: #d9534f;
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 4px 8px;
  margin-bottom: 12px;
  cursor: pointer;
  font-size: 1em;
  transition: background 0.2s;
}

#col-settings-form button:hover {
  background: #b52a24;
}

#save-col-settings {
  background: #009ddc;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 18px;
  font-size: 1em;
  margin-top: 10px;
  cursor: pointer;
  width: 100%;
  transition: background 0.2s;
}

#save-col-settings:hover {
  background: #007bb8;
}

#col-settings-modal .add-field-btn {
  background: #f5e6ad;
  color: #232946;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 1em;
  margin-bottom: 10px;
  cursor: pointer;
  width: 50%;
  transition: background 0.2s;
  display: block;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

#col-settings-modal .add-field-btn:hover {
  background: #fff2ab;
}
/* Utility */
h2, h3, label, .tab, .tab.active {
  color: var(--text-main) !important;
}
.fancy-btn, #save-card {
  background: var(--btn-gradient);
  color: var(--text-main);
}
.fancy-btn:hover, #save-card:hover {
  background: var(--btn-gradient-hover);
}
input, textarea {
  background: var(--bg-main);
  color: var(--text-main);
  border: 1px solid #444;
}
.modal-tab-bar {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 16px;
  padding: 0;
}
.modal-tab-bar .tab {
  flex: 1;
  width: 100%;
  box-sizing: border-box;
}
.modal-content {
  flex: 1 1 auto;
  overflow-y: auto;
  max-height: none;
  min-height: 0;
  padding: 0 15px 0 15px;
}
.modal-content form {
  width: 100%;
}
.modal-stagger-group {
  margin-bottom: 18px;
}
.modal-stagger-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
}
.modal-stagger-group input {
  width: 100%;
  margin-right: 0;
}
/* Add this */
.modal-inner {
  display: flex;
  flex-direction: column;
  height: 70vh; /* or use 100% if you want it to fill the modal */
  min-height: 0;
  padding: 0;
}
.card.card-active {
  outline: 1px solid #ffe066;
  box-shadow: 0 0 18px 4px #ffe06699, 0 0 0 4px #009ddc55;
  transition: box-shadow 0.3s, outline 0.3s;
  z-index: 10;
  position: relative;
  animation: cardShine 1.2s linear 1;
}
@keyframes cardShine {
  0% { box-shadow: 0 0 0 0 #ffe06699, 0 0 0 0 #009ddc55; }
  40% { box-shadow: 0 0 18px 8px #ffe066cc, 0 0 0 4px #009ddc55; }
  100% { box-shadow: 0 0 18px 4px #ffe06699, 0 0 0 4px #009ddc55; }
}
.modal-header {
  cursor: move;
}
.modal-header button {
  cursor: pointer;
}
.matrix-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  margin: 0 0 18px 0;
  padding: 8px 18px 0 18px;
  background: none;
  z-index: 20;
}

.matrix-toolbar .fancy-btn {
  padding: 7px 18px;
  font-size: 1em;
  border-radius: 7px;
  margin: 0;
}

.matrix-toolbar .switch {
  margin-left: 10px;
}