/* Hint App Styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

h1, h2, h3, h4 {
    font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", "Helvetica Neue", Arial;
    font-weight: 400;
    color: var(--fg);
    margin: 0;
}

h3 { margin-top: 0; margin-bottom: 20px; }

/* Header Styles (Harvest-like) */
.header {
    background-color: var(--bg);
    padding: 1rem 2rem;
    color: var(--fg);
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    border-bottom: none;
    box-shadow: none;
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: flex-start;
    gap: 2rem;
}

.header-right {
    display: flex;
    align-items: center;
}

.header-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.header-title-link {
    text-decoration: none;
    color: inherit;
    font-size: 1.4rem;
    font-weight: 400;
}

.header-title-link:hover,
.header-title-link:active {
    color: inherit;
    text-decoration: none;
}

.settings-trigger {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background-color 0.2s;
}

.settings-trigger:hover {
    color: var(--accent);
    background-color: rgba(255, 255, 255, 0.05);
}

.hint-container {
    max-width: 98%;
    margin: 0 auto;
    padding: 10px 20px;
}

.simulation-form {
    display: flex; 
    flex-direction: column;
    align-items: center;
}

.main-column {
    width: 100%;
}

.simulation-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    width: 100%;
    margin-bottom: 30px;
}

/* From Uiverse.io by gharsh11032000 - Adapted */
.card-box {
    background: linear-gradient(#212121, #212121) padding-box,
              linear-gradient(145deg, transparent 35%,#e81cff, #40c9ff) border-box;
    border: 2px solid transparent;
    border-radius: 16px;
    padding: 20px 16px;
    font-size: 14px;
    color: white;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
    height: 100%;
    box-sizing: border-box;
}

.card-box h3 {
    font-size: 1.1rem;
    font-weight: 400;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #414141;
    color: #e0e0e0;
}

/* Override input styles inside cards to match design */
.card-box label {
    display: block;
    margin-bottom: 5px;
    color: #a0a0a0;
    font-weight: 600;
    font-size: 12px;
}

.card-box input, 
.card-box select, 
.card-box textarea,
.card-box .form-control {
    width: 100%;
    padding: 12px 16px;
    border-radius: 8px;
    color: #fff;
    font-family: inherit;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid #414141;
    outline: none;
    transition: all 0.3s ease;
}

.card-box input:focus, 
.card-box select:focus, 
.card-box textarea:focus,
.card-box .form-control:focus {
    outline: none;
    border-color: #e81cff;
    box-shadow: 0 0 0 3px rgba(232, 28, 255, 0.1);
    background-color: rgba(255, 255, 255, 0.05);
}

.card-box .error-text {
    color: #ff4081;
    font-size: 0.85em;
    margin-top: 4px;
}

.card-box small {
    color: #666;
}

.full-width-card {
    /* Kept for compatibility but not used in 4-col layout */
    grid-column: 1 / -1;
}

button.btn-primary-large {
    background: #313131 !important;
    border: 1px solid #414141 !important;
    color: #e0e0e0 !important;
    padding: 14px 40px !important;
    font-size: 1.1rem;
    font-weight: 400 !important;
    border-radius: 6px !important;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    text-transform: none;
}

button.btn-primary-large:hover {
    background-color: #414141 !important;
    border-color: #e0e0e0 !important;
    color: #fff !important;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

@media (max-width: 1100px) {
    .simulation-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .simulation-grid {
        grid-template-columns: 1fr;
    }
    .hint-container {
        padding: 10px;
    }
}

.section-separator {
    margin-top: 25px; 
    margin-bottom: 15px; 
    color: var(--accent); 
    border-bottom: 1px solid var(--line); 
    padding-bottom: 5px;
    font-size: 1.1em;
}

/* Tooltip Styles */
.info-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    margin-left: 8px;
    color: var(--muted);
    font-size: 0.9em;
}

.help-icon {
    width: 16px;
    height: 16px;
    display: block;
}
.info-tooltip .tooltip-text {
    visibility: hidden;
    width: 250px;
    background-color: var(--card);
    color: var(--fg);
    text-align: center;
    border-radius: 4px;
    padding: 8px;
    position: absolute;
    z-index: 10;
    bottom: 125%;
    left: 50%;
    margin-left: -125px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.85rem;
    font-weight: normal;
    font-style: normal;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    border: 1px solid var(--line);
}
.info-tooltip .tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: var(--card) transparent transparent transparent;
}
.info-tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Forms */
label {
    display: block; 
    font-weight: 400; 
    margin-bottom: 5px;
    color: var(--fg);
    font-size: 0.95em;
}

small {
    color: var(--muted);
    display: block; 
    margin-top: 2px;
}

.error-text {
    color: #ff6b6b; 
    margin-top: 2px;
    font-size: 0.9em;
}

.form-group {
    margin-bottom: 15px;
}

.form-control {
    width: 100%;
    padding: 10px;
    background-color: var(--bg);
    border: 1px solid var(--line);
    color: var(--fg);
    border-radius: 4px;
    box-sizing: border-box;
    font-family: inherit;
}

.form-control:focus {
    border-color: var(--accent);
    outline: none;
}

.form-row {
    display: flex; 
    gap: 20px; 
    flex-wrap: wrap;
}

.form-col {
    flex: 1; 
    min-width: 200px; 
    margin-bottom: 15px;
}

button[type="submit"] {
    padding: 12px 20px; 
    font-size: 1.1em; 
    font-weight: 600;
    background-color: var(--accent); 
    color: #1a1a1a; 
    border: none; 
    border-radius: 9999px; 
    cursor: pointer; 
    width: 100%;
    transition: opacity 0.2s;
    font-family: inherit;
}

button[type="submit"]:hover {
    opacity: 0.9;
}

/* Results List */
.result-list {
    list-style: none; 
    padding: 0;
    margin: 0;
}

.result-item {
    padding: 8px 0;
    color: var(--fg);
    display: flex;
    align-items: center;
}

.result-item strong {
    margin-right: 5px;
    font-weight: 400;
}

.result-item.separator {
    margin-bottom: 10px; 
    border-bottom: 1px solid var(--line);
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex; 
    justify-content: center; 
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--card);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 600px; 
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    display: flex; 
    flex-direction: column;
    border: 1px solid var(--line);
}

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

.modal-body { 
    padding: 1.5rem; 
    overflow-y: auto; 
}

.modal-footer {
    display: flex; 
    justify-content: flex-end;
    padding: 1rem 1.5rem; 
    border-top: 1px solid var(--line);
}

.modal-close {
    background: none; 
    border: none; 
    font-size: 1.5rem; 
    cursor: pointer; 
    color: var(--muted);
    padding: 0 8px;
}
.modal-close:hover {
    color: var(--fg);
}

.settings-section { 
    margin-bottom: 2rem; 
}

.settings-section h4 { 
    margin-bottom: 1rem; 
    color: var(--accent); 
    font-size: 1.1em;
}

.modal-subtitle {
    font-size: 0.9em;
    color: var(--muted);
    margin-bottom: 10px;
}

/* Compact form group for IS */
.form-group-compact {
    margin-bottom: 12px;
}
.form-group-compact label {
    margin-bottom: 2px;
}

/* Mode Toggle Switch */
.mode-toggle-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
}

.mode-switch {
    cursor: pointer;
}

.mode-switch input {
    display: none;
}

.mode-switch .mode-btn {
    display: inline-block;
    padding: 10px 24px;
    border: 1px solid var(--line);
    border-radius: 9999px;
    background: var(--card);
    color: var(--muted);
    font-weight: 500;
    transition: all 0.2s ease;
}

.mode-switch input:checked + .mode-btn {
    background: var(--accent);
    color: #1a1a1a;
    border-color: var(--accent);
    font-weight: 700;
    box-shadow: 0 0 10px rgba(110, 231, 183, 0.3);
}

/* IRPP Grid Layout */
.irpp-grid-header {
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 15px;
    margin-bottom: 8px; 
    font-weight: 400; 
    font-size: 0.9em; 
    color: var(--muted);
}

.irpp-grid {
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 15px;
}

.irpp-cell {
    width: 100%;
}

.btn-primary {
    padding: 8px 16px;
    background-color: var(--accent);
    color: #1a1a1a;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}
.btn-primary:hover {
    opacity: 0.9;
}

/* Objectives */
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.objective-tag {
    display: inline-flex;
    align-items: center;
    background-color: var(--bg);
    border: 1px solid var(--line);
    border-radius: 9999px;
    padding: 6px 12px;
    font-size: 0.9em;
    color: var(--fg);
    gap: 6px;
}

.tag-max {
    border-color: var(--accent);
    color: var(--accent);
}

.tag-min {
    border-color: #ff6b6b;
    color: #ff6b6b;
}

.tag-constraint {
    border-color: #60a5fa; /* Blue-400 */
    color: #60a5fa;
}

.tag-icon {
    width: 14px;
    height: 14px;
}

.remove-tag {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1.1em;
    padding: 0;
    margin-left: 4px;
    opacity: 0.7;
    display: flex;
    align-items: center;
}
.remove-tag:hover {
    opacity: 1;
}

.btn-secondary {
    padding: 10px 16px; 
    font-size: 1em; 
    font-weight: 600;
    background-color: var(--bg);
    color: var(--fg);
    border: 1px solid var(--line);
    border-radius: 9999px; 
    cursor: pointer; 
    transition: opacity 0.2s, border-color 0.2s;
    font-family: inherit;
    width: 100%;
}
.btn-secondary:hover {
    border-color: var(--accent);
}

/* Dashboard Styles */
.results-dashboard {
    background-color: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
}

.dashboard-title {
    text-align: center;
    margin-bottom: 30px;
    font-size: 1.5rem;
    font-weight: 600;
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.summary-card {
    /* Styles handled by .card-box */
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.card-accent {
    /* Optional: Special styling for the accent card if needed, 
       but keeping it consistent with card-box for now or just text color */
}

.summary-label {
    font-size: 0.9rem;
    color: #a0a0a0;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-value {
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
}

.card-accent .summary-value {
    color: #e81cff; /* Match the neon pink */
}

.summary-subtext {
    font-size: 0.85rem;
    color: #666;
    opacity: 0.8;
}

/* Details Grid */
.details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

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

.detail-panel {
    /* Styles handled by .card-box */
}

.panel-title {
    margin-bottom: 20px;
    font-size: 1.1rem;
    font-weight: 600;
    padding-bottom: 12px;
    border-bottom: 1px solid #414141;
    color: #e0e0e0;
}

/* Flow List */
.flow-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.flow-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
}

.item-label {
    color: var(--muted);
    display: flex;
    align-items: center;
}

.item-value {
    font-weight: 500;
    color: var(--fg);
    font-family: monospace; /* Align numbers better */
    font-size: 1rem;
}

.text-red .item-value {
    color: #ff6b6b;
}

.flow-subtotal {
    border-top: 1px dashed var(--line);
    padding-top: 12px;
    margin-top: 4px;
    font-weight: 600;
}

.flow-total {
    border-top: 1px solid var(--line);
    padding-top: 12px;
    margin-top: 4px;
    font-weight: 700;
    font-size: 1.05rem;
}

.flow-final {
    background-color: rgba(110, 231, 183, 0.05);
    padding: 12px;
    border-radius: 8px;
    margin-top: 8px;
    font-weight: 700;
    color: var(--accent);
    border: 1px solid rgba(110, 231, 183, 0.2);
}

.card-accent-text .item-value {
    color: var(--accent);
}

/* Update tooltip position for flow items */
.flow-item .info-tooltip .tooltip-text {
    bottom: 150%;
    left: 0;
    margin-left: -20px;
}

.flow-item .info-tooltip .tooltip-text::after {
    left: 30px;
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid currentColor;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.6s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.btn-loading {
    opacity: 0.7;
    cursor: wait !important;
    pointer-events: none;
}

/* Table Styles for Pareto */
.table-container {
    overflow-x: auto;
    margin-top: 20px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

th, td {
    padding: 12px 16px;
    text-align: right;
    border-bottom: 1px solid var(--line);
    color: var(--fg);
}

th {
    font-weight: 600;
    color: var(--muted);
    background-color: rgba(255, 255, 255, 0.02);
}

tr:last-child td {
    border-bottom: none;
}

/* Constraint Rows (New UX) */
.constraint-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 15px;
    margin-bottom: 10px;
    flex-wrap: wrap;
    transition: border-color 0.2s;
}

.constraint-row:hover {
    border-color: var(--accent);
}

.constraint-row .label-col {
    font-weight: 500;
    min-width: 150px;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.constraint-row .controls-col {
    display: flex;
    align-items: center;
    gap: 10px;
}

.constraint-row select, .constraint-row input {
    padding: 6px 10px;
    border: 1px solid var(--line);
    background: var(--card); 
    color: var(--fg);
    border-radius: 4px;
    font-size: 0.9em;
}

.constraint-row select:focus, .constraint-row input:focus {
    border-color: var(--accent);
    outline: none;
}

.constraint-row input {
    width: 100px;
}

.constraint-row .remove-btn {
    margin-left: 10px;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 1.2em;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.2s, background-color 0.2s;
}

.constraint-row .remove-btn:hover {
    color: #ff6b6b;
    background-color: rgba(255, 107, 107, 0.1);
}

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

/* Collapsible Sections */
.collapsible-header {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: color 0.2s;
}

.collapsible-header:hover {
    opacity: 0.8;
}

.collapsible-header .chevron-icon {
    transition: transform 0.3s ease;
    width: 20px;
    height: 20px;
    color: var(--accent);
}

.collapsible-header.collapsed .chevron-icon {
    transform: rotate(-90deg);
}

/* When collapsed, content is hidden via JS inline style, but we can set defaults if needed */
.collapsible-content {
    /* transition: all 0.3s ease;  - Height transition is tricky with auto height, skipping for now */
}


/* Modal / Alert Popup */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background-color: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 24px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    position: relative;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 12px;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--fg);
}

.modal-close {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    padding: 4px;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--accent);
}

.modal-body {
    color: var(--fg);
    margin-bottom: 24px;
    line-height: 1.5;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
}

.modal-btn {
    background-color: var(--accent);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: opacity 0.2s;
}

.modal-btn:hover {
    opacity: 0.9;
}