/* ═══════════════════════════════════════════════════
   Ordi.io — Custom Styles & Animations
   Dark Premium Theme (Apple/Xbox Aesthetic)
   ═══════════════════════════════════════════════════ */

/* ── Base ── */
::selection {
    background: rgba(16, 185, 129, 0.3);
    color: #fff;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #3f3f46;
    border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
    background: #52525b;
}

/* ── Glassmorphism Navbar ── */
.navbar-glass {
    background: rgba(9, 9, 11, 0.75);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
}

/* ── Navigation Tabs ── */
.nav-tab {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #94a3b8;
    border-radius: 0.75rem;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    cursor: pointer;
    border: 1px solid transparent;
    background: transparent;
}
.nav-tab:hover {
    color: #e2e8f0;
    background: rgba(39, 39, 42, 0.6);
}
.nav-tab.active {
    color: #10b981;
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.2);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.08);
}
.nav-tab .tab-icon {
    font-size: 0.875rem;
}

.mobile-nav-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #94a3b8;
    border-radius: 0.75rem;
    transition: all 0.2s ease;
    cursor: pointer;
    border: 1px solid transparent;
    background: transparent;
    text-align: left;
}
.mobile-nav-tab:hover {
    color: #e2e8f0;
    background: rgba(39, 39, 42, 0.6);
}
.mobile-nav-tab.active {
    color: #10b981;
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.2);
}

/* ── Module Sections ── */
.module-section {
    display: none;
    animation: fadeSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.module-section.active {
    display: block;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Module Header ── */
.module-header {
    margin-bottom: 1.5rem;
}
.module-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border-radius: 9999px;
    border: 1px solid;
    margin-bottom: 0.75rem;
}
.module-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.025em;
    line-height: 1.2;
}
.module-subtitle {
    font-size: 0.9375rem;
    color: #64748b;
    margin-top: 0.5rem;
    max-width: 36rem;
    line-height: 1.5;
}

/* ── Cards ── */
.card {
    background: rgba(24, 24, 27, 0.7);
    border: 1px solid rgba(39, 39, 42, 0.6);
    border-radius: 1rem;
    padding: 1.5rem;
    backdrop-filter: blur(8px);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.card:hover {
    border-color: rgba(63, 63, 70, 0.6);
}
.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ── Theory Accordion ── */
.theory-accordion {
    background: rgba(24, 24, 27, 0.5);
    border: 1px solid rgba(39, 39, 42, 0.4);
    border-radius: 1rem;
    overflow: hidden;
    transition: border-color 0.3s ease;
}
.theory-accordion[open] {
    border-color: rgba(14, 165, 233, 0.2);
}
.theory-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    color: #e2e8f0;
    transition: background 0.2s ease;
    list-style: none;
}
.theory-summary::-webkit-details-marker {
    display: none;
}
.theory-summary:hover {
    background: rgba(39, 39, 42, 0.3);
}
.theory-accordion[open] .theory-summary .chevron {
    transform: rotate(180deg);
}
.theory-content {
    padding: 0 1.25rem 1.25rem;
    font-size: 0.8125rem;
    color: #94a3b8;
    line-height: 1.7;
    animation: accordionSlide 0.3s ease;
}
@keyframes accordionSlide {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}
.theory-formula {
    background: rgba(9, 9, 11, 0.6);
    border: 1px solid rgba(39, 39, 42, 0.5);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-top: 0.75rem;
    overflow-x: auto;
}

/* ── Inputs ── */
.input-group {
    display: flex;
    flex-direction: column;
}
.input-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: 0.5rem;
    letter-spacing: 0.01em;
}
.input-field {
    background: rgba(39, 39, 42, 0.5);
    border: 1px solid rgba(63, 63, 70, 0.5);
    border-radius: 0.75rem;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    color: #e2e8f0;
    font-family: inherit;
    transition: all 0.2s ease;
    outline: none;
    width: 100%;
}
.input-field:focus {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1), 0 0 20px rgba(16, 185, 129, 0.05);
}
.input-field.error {
    border-color: #f43f5e;
    box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.1);
}
.input-field-sm {
    background: rgba(39, 39, 42, 0.5);
    border: 1px solid rgba(63, 63, 70, 0.5);
    border-radius: 0.625rem;
    padding: 0.5rem 0.625rem;
    font-size: 0.8125rem;
    color: #e2e8f0;
    font-family: inherit;
    transition: all 0.2s ease;
    outline: none;
    width: 5rem;
    text-align: center;
}
.input-field-sm:focus {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}
.input-field-sm.error {
    border-color: #f43f5e;
    box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.1);
}
.input-select {
    background: rgba(39, 39, 42, 0.5);
    border: 1px solid rgba(63, 63, 70, 0.5);
    border-radius: 0.75rem;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    color: #e2e8f0;
    font-family: inherit;
    transition: all 0.2s ease;
    outline: none;
    cursor: pointer;
    appearance: auto;
    width: 100%;
}
.input-select:focus {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}
.input-select-sm {
    background: rgba(39, 39, 42, 0.5);
    border: 1px solid rgba(63, 63, 70, 0.5);
    border-radius: 0.625rem;
    padding: 0.5rem 0.625rem;
    font-size: 0.8125rem;
    color: #e2e8f0;
    font-family: inherit;
    transition: all 0.2s ease;
    outline: none;
    cursor: pointer;
    min-width: 5rem;
}
.input-select-sm:focus {
    border-color: #10b981;
}

/* ── Matrix Grid ── */
.matrix-grid {
    display: inline-grid;
    gap: 0.375rem;
    padding: 0.5rem;
    background: rgba(9, 9, 11, 0.4);
    border-radius: 0.75rem;
    border: 1px solid rgba(39, 39, 42, 0.3);
}
.matrix-input {
    width: 3.5rem;
    height: 2.25rem;
    text-align: center;
    background: rgba(39, 39, 42, 0.6);
    border: 1px solid rgba(63, 63, 70, 0.4);
    border-radius: 0.5rem;
    color: #e2e8f0;
    font-size: 0.8125rem;
    font-family: 'JetBrains Mono', monospace;
    outline: none;
    transition: all 0.2s ease;
}
.matrix-input:focus {
    border-color: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.15);
    background: rgba(39, 39, 42, 0.8);
}
.matrix-input.error {
    border-color: #f43f5e;
}
.matrix-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: #64748b;
    text-align: center;
    padding: 0.125rem 0;
}

/* ── Buttons ── */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6875rem 1.5rem;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 0.75rem;
    border: none;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.25), inset 0 1px 0 rgba(255,255,255,0.1);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 25px rgba(16, 185, 129, 0.35), inset 0 1px 0 rgba(255,255,255,0.1);
}
.btn-primary:active {
    transform: translateY(0);
}
.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6875rem 1.25rem;
    background: rgba(39, 39, 42, 0.5);
    color: #94a3b8;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.75rem;
    border: 1px solid rgba(63, 63, 70, 0.5);
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-secondary:hover {
    background: rgba(63, 63, 70, 0.5);
    color: #e2e8f0;
    border-color: rgba(82, 82, 91, 0.6);
}
.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6875rem 1.25rem;
    background: transparent;
    color: #0ea5e9;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.75rem;
    border: 1px solid rgba(14, 165, 233, 0.25);
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-ghost:hover {
    background: rgba(14, 165, 233, 0.08);
    border-color: rgba(14, 165, 233, 0.4);
}
.btn-sm-primary {
    padding: 0.5rem 0.875rem;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: 0.625rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.btn-sm-primary:hover {
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* ── Results Table ── */
.results-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.8125rem;
}
.results-table thead th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    border-bottom: 1px solid rgba(39, 39, 42, 0.6);
    background: rgba(9, 9, 11, 0.3);
}
.results-table thead th:first-child {
    border-top-left-radius: 0.75rem;
}
.results-table thead th:last-child {
    border-top-right-radius: 0.75rem;
}
.results-table tbody td {
    padding: 0.625rem 1rem;
    color: #cbd5e1;
    border-bottom: 1px solid rgba(39, 39, 42, 0.3);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8125rem;
}
.results-table tbody tr:hover {
    background: rgba(39, 39, 42, 0.2);
}
.results-table tbody tr.optimal {
    background: rgba(16, 185, 129, 0.08);
}
.results-table tbody tr.optimal td {
    color: #10b981;
    font-weight: 600;
}

/* ── Simplex Tables ── */
.simplex-table-card {
    background: rgba(24, 24, 27, 0.7);
    border: 1px solid rgba(39, 39, 42, 0.6);
    border-radius: 1rem;
    padding: 1.25rem;
    overflow-x: auto;
}
.simplex-table-card .iteration-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.simplex-table-card .iteration-label .badge {
    background: rgba(14, 165, 233, 0.1);
    color: #0ea5e9;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 700;
    border: 1px solid rgba(14, 165, 233, 0.2);
}
.simplex-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
}
.simplex-table th {
    padding: 0.5rem 0.625rem;
    text-align: center;
    font-weight: 600;
    color: #64748b;
    border-bottom: 1px solid rgba(39, 39, 42, 0.6);
    background: rgba(9, 9, 11, 0.3);
    white-space: nowrap;
}
.simplex-table td {
    padding: 0.5rem 0.625rem;
    text-align: center;
    color: #cbd5e1;
    border-bottom: 1px solid rgba(39, 39, 42, 0.2);
    white-space: nowrap;
}
.simplex-table td.pivot-cell {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    font-weight: 700;
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 0.375rem;
}
.simplex-table td.pivot-col {
    background: rgba(16, 185, 129, 0.05);
}
.simplex-table td.pivot-row {
    background: rgba(14, 165, 233, 0.05);
}
.simplex-table tr.z-row td {
    border-top: 2px solid rgba(39, 39, 42, 0.6);
    font-weight: 600;
    color: #f59e0b;
}

/* ── Hungarian Steps ── */
.hungarian-step {
    background: rgba(24, 24, 27, 0.7);
    border: 1px solid rgba(39, 39, 42, 0.6);
    border-radius: 1rem;
    padding: 1.25rem;
    overflow-x: auto;
}
.hungarian-step .step-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: 0.75rem;
}
.hungarian-matrix {
    display: inline-grid;
    gap: 2px;
    background: rgba(9, 9, 11, 0.4);
    border-radius: 0.5rem;
    padding: 0.5rem;
    border: 1px solid rgba(39, 39, 42, 0.3);
}
.hungarian-cell {
    width: 3rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8125rem;
    color: #cbd5e1;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
}
.hungarian-cell.zero {
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
    font-weight: 600;
}
.hungarian-cell.assigned {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    font-weight: 700;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.2);
}
.hungarian-cell.covered-row {
    border-top: 2px solid rgba(14, 165, 233, 0.5);
    border-bottom: 2px solid rgba(14, 165, 233, 0.5);
}
.hungarian-cell.covered-col {
    border-left: 2px solid rgba(245, 158, 11, 0.5);
    border-right: 2px solid rgba(245, 158, 11, 0.5);
}

/* ── Result Interpretation ── */
.result-interpretation {
    background: rgba(24, 24, 27, 0.7);
    border: 1px solid rgba(39, 39, 42, 0.6);
    border-left: 3px solid #10b981;
    border-radius: 0 1rem 1rem 0;
    padding: 1.25rem 1.5rem;
}
.result-interpretation h4 {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #10b981;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.result-interpretation p {
    font-size: 0.875rem;
    color: #94a3b8;
    line-height: 1.7;
}
.result-interpretation .highlight {
    color: #10b981;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

/* ── Chart ── */
.chart-container {
    position: relative;
    width: 100%;
    max-height: 500px;
    background: rgba(9, 9, 11, 0.4);
    border-radius: 0.75rem;
    padding: 1rem;
    border: 1px solid rgba(39, 39, 42, 0.3);
}

/* ── Tags ── */
.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}
.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    background: rgba(39, 39, 42, 0.5);
    border: 1px solid rgba(63, 63, 70, 0.4);
    border-radius: 0.5rem;
    font-size: 0.75rem;
    color: #94a3b8;
    font-family: 'JetBrains Mono', monospace;
}
.tag .tag-remove {
    color: #f43f5e;
    cursor: pointer;
    font-size: 0.875rem;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.2s;
}
.tag .tag-remove:hover {
    opacity: 1;
}

/* ── Toast Notifications ── */
.toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    background: rgba(24, 24, 27, 0.95);
    border: 1px solid rgba(63, 63, 70, 0.5);
    border-radius: 0.75rem;
    font-size: 0.8125rem;
    color: #e2e8f0;
    backdrop-filter: blur(12px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: toastIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 22rem;
}
.toast.toast-error {
    border-left: 3px solid #f43f5e;
}
.toast.toast-success {
    border-left: 3px solid #10b981;
}
.toast.toast-info {
    border-left: 3px solid #0ea5e9;
}
.toast.toast-out {
    animation: toastOut 0.3s ease forwards;
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100%); }
}

/* ── Constraint Row ── */
.constraint-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 0.5rem 0.75rem;
    background: rgba(9, 9, 11, 0.3);
    border: 1px solid rgba(39, 39, 42, 0.3);
    border-radius: 0.75rem;
    animation: fadeSlideIn 0.3s ease;
}
.constraint-label {
    font-size: 0.6875rem;
    font-weight: 700;
    color: #64748b;
    min-width: 1.5rem;
    text-transform: uppercase;
}

/* ── Pulse animation for loading ── */
@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 5px rgba(16, 185, 129, 0.2); }
    50% { box-shadow: 0 0 20px rgba(16, 185, 129, 0.4); }
}
.solving {
    animation: pulse-glow 1.5s ease-in-out infinite;
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .module-title {
        font-size: 1.375rem;
    }
    .card {
        padding: 1rem;
    }
    .input-field-sm {
        width: 4rem;
    }
    .matrix-input {
        width: 2.75rem;
        height: 2rem;
        font-size: 0.75rem;
    }
    .constraint-row {
        padding: 0.375rem 0.5rem;
        gap: 0.375rem;
    }
}
