/* Roadmap application specific styles */

/* Override common.css variables for app-specific transparency */
:root {
  --bg-card: rgba(15, 23, 42, 0.7);
  --border-soft: rgba(148, 163, 184, 0.15);
  --input-bg: rgba(2, 6, 23, 0.5);
  --input-border: rgba(148, 163, 184, 0.3);
  --danger: #f43f5e;
  --success: #10b981;
}

/* Universal box-sizing */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
}

/* Adjust navigation max-width for app */
.top-nav-inner {
  max-width: 1400px;
}

/* --- APP LAYOUT & COMPONENTS --- */
.app-container {
  padding: 0 20px 20px 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border-soft);
}

h1 {
  margin: 0;
  font-size: 24px;
  background: linear-gradient(to right, #38bdf8, #a855f7);
  -webkit-background-clip: text;
  color: transparent;
  font-weight: 600;
}

h2 {
  margin: 0;
  font-weight: 600;
}

.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 24px;
  align-items: flex-start;
}

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

/* Panels */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  backdrop-filter: blur(12px);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.panel h2 {
  font-size: 14px;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel h2::before {
  content: '';
  display: block;
  width: 4px;
  height: 14px;
  background: var(--accent);
  border-radius: 2px;
}

.panel small {
  font-size: 11px;
  color: var(--text-sub);
  display: block;
  margin-bottom: 12px;
}

/* Forms & Inputs */
label {
  font-size: 11px;
  color: var(--accent);
  display: block;
  margin-bottom: 4px;
  font-weight: 500;
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-main);
  border-radius: 6px;
  transition: border-color 0.2s, background 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.1);
}

/* Custom Dropdown Arrow & Colors */
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%2338bdf8%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 10px top 50%;
  background-size: 10px auto;
  padding-right: 30px;
}

select option {
  background-color: #020617;
  color: #e5e7eb;
  padding: 8px;
}

textarea {
  resize: vertical;
  min-height: 50px;
  max-height: 140px;
}

/* Buttons */
button {
  font-size: 12px;
  padding: 8px 14px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.1s, box-shadow 0.2s;
}

button:active {
  transform: translateY(1px);
}

button.primary-btn,
#addProjectBtn,
#addSubProjectBtn,
#addFeatureBtn {
  background: linear-gradient(to right, var(--accent), var(--accent-2));
  color: #020617;
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}

button.primary-btn:hover,
#addProjectBtn:hover,
#addSubProjectBtn:hover,
#addFeatureBtn:hover {
  box-shadow: 0 6px 16px rgba(56, 189, 248, 0.4);
}

button.secondary {
  background: transparent;
  border: 1px solid var(--input-border);
  color: var(--text-sub);
}

button.secondary:hover {
  color: var(--text-main);
  border-color: var(--text-main);
  background: rgba(255,255,255,0.05);
}

button.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.5);
  color: #fda4af;
}

button.btn-danger:hover {
  background: rgba(244, 63, 94, 0.25);
  color: #fff;
}

button.btn-icon {
  padding: 4px 8px;
  font-size: 10px;
  background: transparent;
  color: var(--text-sub);
  border: 1px solid var(--border-soft);
}

button.btn-icon:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(244, 63, 94, 0.1);
}

.form-row {
  margin-bottom: 12px;
}

.form-row.inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.priority-input {
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.priority-input label {
  margin-bottom: 0;
  color: var(--text-main);
  font-weight: normal;
  flex: 1;
}

.priority-input span {
  width: 20px;
  text-align: right;
  color: var(--accent);
  font-weight: bold;
}

input[type=range] {
  accent-color: var(--accent);
}

/* Table */
.table-container {
  overflow-x: auto;
  max-width: 100%;
  width: 100%;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th {
  text-align: left;
  padding: 10px 8px;
  color: var(--text-sub);
  font-weight: 600;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  user-select: none;
}

th:hover {
  color: var(--accent);
}

th.sort-asc::after {
  content: " ▲";
  font-size: 10px;
  color: var(--accent);
}

th.sort-desc::after {
  content: " ▼";
  font-size: 10px;
  color: var(--accent);
}

td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

tr:hover td {
  background: rgba(255,255,255,0.03);
}

tr.dragging {
  opacity: 0.4;
  background: rgba(56, 189, 248, 0.1);
}

select.feature-prio,
select.feature-quarter {
  background-color: transparent;
  background-image: none;
  border: 1px solid transparent;
  color: var(--text-main);
  padding: 2px;
  cursor: pointer;
}

select.feature-prio:hover,
select.feature-quarter:hover {
  border-color: var(--border-soft);
  background-color: var(--bg-body);
}

select.feature-prio option,
select.feature-quarter option {
  background-color: #020617;
  color: #e5e7eb;
}

.priority-high {
  color: #f87171;
  background: rgba(248, 113, 113, 0.15);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
}

.priority-medium {
  color: #facc15;
  background: rgba(250, 204, 21, 0.15);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
}

.priority-low {
  color: #4ade80;
  background: rgba(74, 222, 128, 0.15);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
}

.quarter-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.actions-bar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.actions-bar-left {
  margin-right: auto;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.2);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-soft);
}

.filter-group span {
  font-size: 10px;
  color: var(--text-sub);
  text-transform: uppercase;
}

.filter-group select,
.filter-group input {
  background: transparent;
  border: none;
  padding: 0;
  width: auto;
  font-size: 11px;
  color: var(--text-main);
  background-image: none;
}

.filter-group select option {
  background-color: #020617;
}

/* Gantt Mini */
.gantt-header {
  display: grid;
  grid-template-columns: 100px 1fr;
  font-size: 11px;
  color: var(--text-sub);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-soft);
}

.gantt-header-timeline {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  gap: 2px;
  text-align: center;
  font-size: 10px;
  overflow-x: auto;
}

.gantt-body {
  max-height: 250px;
  overflow-y: auto;
  padding-right: 6px;
}

.gantt-row {
  display: grid;
  grid-template-columns: 100px 1fr;
  align-items: center;
  margin: 6px 0;
  font-size: 11px;
}

.gantt-label {
  padding-right: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-sub);
}

.gantt-track {
  position: relative;
  height: 12px;
  background: rgba(255,255,255,0.05);
  border-radius: 999px;
}

.gantt-bar {
  position: absolute;
  top: 2px;
  height: 8px;
  border-radius: 999px;
  box-shadow: 0 0 10px rgba(0,0,0,0.3);
}

.hint {
  font-size: 11px;
  color: var(--text-sub);
  margin-top: 8px;
  opacity: 0.7;
}

.effort-input {
  width: 50px !important;
  padding: 2px 4px !important;
  text-align: center;
}

hr {
  border: none;
  border-top: 1px solid var(--border-soft);
  margin: 16px 0;
}

/* --- MOBILE CARD VIEW FOR FEATURES --- */
.mobile-cards {
  display: none;
  width: 100%;
  box-sizing: border-box;
}

.mobile-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  position: relative;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.mobile-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
  gap: 8px;
  width: 100%;
}

.mobile-card-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.mobile-card-title .project-name {
  font-size: 9px;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-card-title .subproject-name {
  font-size: 10px;
  color: var(--accent);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-card-title .feature-name {
  font-size: 13px;
  color: var(--text-main);
  font-weight: 600;
  margin-bottom: 4px;
  word-break: break-word;
  overflow-wrap: break-word;
  line-height: 1.3;
}

.mobile-card-description {
  font-size: 11px;
  color: var(--text-sub);
  margin-bottom: 10px;
  line-height: 1.4;
  font-style: italic;
  word-break: break-word;
  overflow-wrap: break-word;
}

.mobile-card-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-soft);
  width: 100%;
}

.mobile-card-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.mobile-card-meta-label {
  font-size: 9px;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.mobile-card-meta-value {
  font-size: 12px;
  color: var(--text-main);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 6px;
  align-items: center;
  width: 100%;
}

.mobile-card-actions select {
  min-width: 0;
  font-size: 11px;
  padding: 6px 6px;
  box-sizing: border-box;
}

.mobile-card-delete {
  padding: 6px 10px;
  font-size: 10px;
  white-space: nowrap;
  box-sizing: border-box;
}

/* Special handling for card actions on very narrow screens */
@media (max-width: 380px) {
  .mobile-card-actions {
    grid-template-columns: 1fr;
  }

  .mobile-card-actions select,
  .mobile-card-delete {
    width: 100%;
  }
}

/* --- MOBILE RESPONSIVE STYLES --- */
@media (max-width: 768px) {
  /* Force proper viewport sizing */
  html, body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    position: relative;
  }

  /* Prevent any child from causing horizontal scroll */
  * {
    max-width: 100%;
  }

  /* App container */
  .app-container {
    padding: 0 8px 12px 8px;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    overflow-x: hidden;
  }

  /* Header adjustments */
  .header-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 12px;
    padding-bottom: 10px;
  }

  h1 {
    font-size: 18px;
  }

  /* Layout - single column */
  .layout {
    grid-template-columns: 1fr !important;
    gap: 12px;
    width: 100%;
  }

  /* Hide left panel by default on mobile */
  #leftPanel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
  }

  #leftPanel.mobile-visible {
    max-height: 5000px;
  }

  #toggleLeftPanelBtn {
    width: 100%;
    margin-bottom: 10px !important;
    font-size: 12px !important;
    padding: 8px 12px;
  }

  /* Panel adjustments */
  .panel {
    padding: 10px;
    margin-bottom: 10px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
  }

  .panel h2 {
    font-size: 11px;
    margin-bottom: 6px;
  }

  .panel small {
    font-size: 10px;
    margin-bottom: 8px;
  }

  /* Actions bar - stack vertically */
  .actions-bar {
    flex-direction: column;
    gap: 6px;
    width: 100%;
  }

  .actions-bar-left {
    width: 100%;
    margin-right: 0;
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    width: 100%;
    justify-content: space-between;
    padding: 6px 8px;
  }

  .filter-group span {
    min-width: 50px;
    font-size: 9px;
    white-space: nowrap;
  }

  .filter-group select,
  .filter-group input {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    padding: 6px 8px;
  }

  #clearAllBtn,
  #importBtn,
  #exportBtn {
    width: 100%;
    padding: 10px 14px;
    font-size: 13px;
  }

  /* HIDE TABLE, SHOW CARDS on mobile */
  .table-container {
    display: none !important;
    visibility: hidden;
    max-width: 0;
    max-height: 0;
    overflow: hidden;
  }

  .mobile-cards {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
  }

  /* Gantt improvements */
  .gantt-header {
    grid-template-columns: 60px 1fr;
    font-size: 8px;
    gap: 4px;
  }

  .gantt-row {
    grid-template-columns: 60px 1fr;
    font-size: 8px;
    gap: 4px;
  }

  .gantt-label {
    font-size: 8px;
    padding-right: 4px;
  }

  .gantt-body {
    max-height: 180px;
  }

  #openGanttWindowBtn {
    font-size: 10px;
    padding: 6px 8px;
  }

  /* Form inputs - prevent overflow */
  input[type="text"],
  input[type="number"],
  select,
  textarea {
    font-size: 16px; /* Prevent zoom on iOS */
    width: 100%;
    box-sizing: border-box;
    padding: 8px;
    max-width: 100%;
  }

  select {
    background-size: 8px auto;
    background-position: right 8px top 50%;
    padding-right: 26px;
  }

  label {
    font-size: 10px;
  }

  /* Override select styles in filter groups for mobile */
  .filter-group select {
    background-size: 7px auto;
    background-position: right 6px top 50%;
    padding-right: 22px;
  }

  /* Mobile card select overrides */
  .mobile-card-actions select {
    background-size: 7px auto;
    background-position: right 4px top 50%;
    padding-right: 18px;
  }

  /* Buttons */
  button {
    font-size: 13px;
    padding: 9px 14px;
    box-sizing: border-box;
  }

  button.secondary {
    font-size: 12px;
  }

  /* Hint text */
  .hint {
    font-size: 9px;
    text-align: center;
    padding: 0 8px;
    line-height: 1.4;
  }

  /* Form row adjustments */
  .form-row {
    margin-bottom: 8px;
    width: 100%;
  }

  .form-row.inline {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  /* Add feature button full width */
  #addProjectBtn,
  #addSubProjectBtn,
  #addFeatureBtn {
    width: 100%;
  }

  /* Priority controls compact */
  .priority-input {
    font-size: 10px;
    gap: 6px;
  }

  .priority-input input[type=range] {
    flex: 1;
    min-width: 0;
  }

  .priority-input label {
    font-size: 10px;
    margin-bottom: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .priority-input span {
    min-width: 18px;
  }

  /* Nav tag visibility */
  .nav-tag {
    display: none;
  }

  /* Word breaking for long text */
  td, th, .mobile-card-title, .gantt-label {
    word-break: break-word;
    overflow-wrap: break-word;
  }
}

/* Smaller phones */
@media (max-width: 480px) {
  .app-container {
    padding: 0 6px 10px 6px;
  }

  h1 {
    font-size: 16px;
  }

  .panel {
    padding: 8px;
    margin-bottom: 8px;
  }

  .panel h2 {
    font-size: 10px;
  }

  .panel small {
    font-size: 9px;
  }

  .mobile-card {
    padding: 10px;
    margin-bottom: 8px;
  }

  .mobile-card-title .project-name {
    font-size: 8px;
  }

  .mobile-card-title .subproject-name {
    font-size: 9px;
  }

  .mobile-card-title .feature-name {
    font-size: 12px;
  }

  .mobile-card-description {
    font-size: 10px;
  }

  .mobile-card-meta {
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin-bottom: 8px;
    padding-bottom: 8px;
  }

  .mobile-card-meta-item {
    gap: 1px;
  }

  .mobile-card-meta-label {
    font-size: 8px;
  }

  .mobile-card-meta-value {
    font-size: 11px;
  }

  .mobile-card-actions {
    flex-direction: column;
    gap: 6px;
  }

  .mobile-card-actions select {
    width: 100%;
    font-size: 12px;
    padding: 6px 8px;
  }

  .mobile-card-delete {
    width: 100%;
    padding: 6px 10px;
    font-size: 10px;
  }

  .filter-group {
    padding: 5px 6px;
  }

  .filter-group span {
    font-size: 8px;
    min-width: 45px;
  }

  .filter-group select,
  .filter-group input {
    font-size: 13px;
    padding: 5px 6px;
  }

  #clearAllBtn,
  #importBtn,
  #exportBtn {
    padding: 8px 12px;
    font-size: 12px;
  }

  .gantt-header {
    grid-template-columns: 50px 1fr;
    font-size: 7px;
  }

  .gantt-row {
    grid-template-columns: 50px 1fr;
    font-size: 7px;
  }

  .gantt-label {
    font-size: 7px;
  }

  input[type="text"],
  input[type="number"],
  select,
  textarea {
    font-size: 16px;
    padding: 7px;
  }

  label {
    font-size: 9px;
  }

  .priority-input {
    font-size: 9px;
    gap: 4px;
  }

  .priority-input label {
    font-size: 9px;
  }

  .priority-input span {
    min-width: 16px;
    font-size: 9px;
  }
}

/* Landscape mode on mobile */
@media (max-width: 900px) and (orientation: landscape) {
  .layout {
    grid-template-columns: 280px 1fr !important;
  }

  #leftPanel {
    max-height: none !important;
  }

  #leftPanel.mobile-visible {
    max-height: none;
  }
}

/* Tablet-specific adjustments */
@media (min-width: 769px) and (max-width: 1000px) {
  .layout {
    grid-template-columns: 280px 1fr;
  }

  .app-container {
    padding: 0 16px 16px 16px;
  }
}
