/* Operations Dashboard demo - dashboard styles.
   The explainer banner at the top (.demo-intro) is styled by ../demo-data/demo-kit.css. */

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

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f5;
    color: #222;
    overflow-x: hidden;
}

h1, h2, h3, p {
    margin: 0;
}

.demo-title-sub {
    display: block;
    font-size: 14px;
    font-weight: 400;
    color: #4b5563;
    margin-top: 2px;
}

.dashboard-container {
    display: flex;
    flex-direction: column;
    min-height: 60vh;
}

/* Header */
.dashboard-header {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    padding: 12px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.app-name {
    font-size: 20px;
    font-weight: 600;
}

.user-info {
    font-size: 13px;
    opacity: 0.9;
}

/* Tab Menu (scrolls sideways on narrow screens instead of hiding behind a menu) */
.tab-menu {
    background: white;
    display: flex;
    border-bottom: 2px solid #e0e0e0;
    padding: 0 22px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    overflow-x: auto;
    scrollbar-width: thin;
}

.tab-btn {
    flex: 0 0 auto;
    background: none;
    border: none;
    padding: 13px 16px;
    font: inherit;
    font-size: 15px;
    font-weight: 500;
    color: #555;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
}

.tab-btn:hover {
    color: #2a5298;
    background: #f8f8f8;
}

.tab-btn.active {
    color: #2a5298;
    border-bottom-color: #2a5298;
}

.tab-btn:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible {
    outline: 2px solid #1f4fa3;
    outline-offset: 2px;
}

/* Tab Content */
.tab-content {
    flex: 1;
    padding: 20px 30px 30px;
}

.tab-pane {
    display: none;
    animation: fadeIn 0.25s;
}

.tab-pane.active {
    display: block;
}

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

.tab-pane h2 {
    color: #1e3c72;
    margin-bottom: 14px;
    font-size: 22px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat-card {
    background: white;
    padding: 14px 16px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-top: 4px solid #2a5298;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.stat-card.tone-warn { border-top-color: #e67e22; }
.stat-card.tone-good { border-top-color: #27ae60; }

.stat-title {
    font-size: 12px;
    color: #555;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 600;
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: #2a5298;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.stat-card.tone-warn .stat-value { color: #b9560b; }

.stat-sub {
    font-size: 13px;
    color: #666;
    margin-top: 4px;
}

.stat-card button {
    margin-top: auto;
    align-self: flex-start;
    background: #2a5298;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 5px;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    transition: background 0.2s;
}

.stat-card .stat-sub + button,
.stat-card .stat-value + button {
    margin-top: 10px;
}

.stat-card button:hover {
    background: #1e3c72;
}

/* Panels */
.panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
    gap: 18px;
}

.details-section {
    background: white;
    padding: 16px 18px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-width: 0;
}

.details-section h3 {
    color: #1e3c72;
    font-size: 17px;
    margin-bottom: 8px;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px 12px;
}

.link-btn {
    background: none;
    border: none;
    color: #1f4fa3;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 0;
    text-decoration: underline;
}

/* Filters */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    align-items: flex-end;
    margin-bottom: 8px;
}

.filters-bare {
    margin: 0 0 12px;
}

.filters label {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 12px;
    font-weight: 600;
    color: #555;
    min-width: 0;
}

.filters label.check {
    flex-direction: row;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    padding-bottom: 8px;
}

.filters input[type="search"],
.filters select {
    font: inherit;
    font-size: 14px;
    padding: 7px 9px;
    border: 1px solid #c8ccd2;
    border-radius: 6px;
    background: white;
    max-width: 100%;
}

.filters input[type="search"] {
    width: 220px;
}

.export-btn,
.secondary-btn {
    font: inherit;
    font-size: 14px;
    padding: 7px 14px;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid #2a5298;
}

.export-btn {
    background: #2a5298;
    color: white;
}

.export-btn:hover {
    background: #1e3c72;
}

.secondary-btn {
    background: white;
    color: #2a5298;
}

.secondary-btn:hover {
    background: #eef3fb;
}

.table-note {
    font-size: 13px;
    color: #666;
    margin: 4px 0 6px;
}

/* Tables: wide tables scroll inside their own box, never the page */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

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

table th {
    background: #e4e6ea;
    padding: 9px 10px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #d0d4da;
    white-space: nowrap;
}

table th.sortable {
    cursor: pointer;
    user-select: none;
}

table th.sortable:hover {
    background: #d5d9df;
}

table th.sort-asc::after { content: ' \25B2'; font-size: 0.75em; }
table th.sort-desc::after { content: ' \25BC'; font-size: 0.75em; }

table td {
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    vertical-align: top;
}

table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

table tbody tr:hover {
    background: #f7f9fc;
}

table td.nowrap {
    white-space: nowrap;
}

td.empty {
    text-align: center;
    color: #767676;
    padding: 18px;
}

.cell-sub {
    font-size: 12px;
    color: #767676;
}

.neg { color: #c0392b; font-weight: 600; }
.pos { color: #1e8449; }

.order-link {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-weight: 600;
    color: #2a5298;
    text-decoration: underline;
    cursor: pointer;
    white-space: nowrap;
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1.5;
}

.badge-gray { background: #eceff3; color: #44505e; }
.badge-blue { background: #e3ecfb; color: #1e3c72; }
.badge-green { background: #e3f4ea; color: #1e6b3d; }
.badge-amber { background: #fff1d6; color: #8a5300; }
.badge-red { background: #fde4e1; color: #a12a1c; }
.badge-muted { background: #f1f1f1; color: #777; text-decoration: line-through; }

/* Charts */
.chart-container {
    position: relative;
    height: 340px;
    margin: 6px 0 14px;
}

.chart-fallback {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #666;
    background: #fafafa;
    border: 1px dashed #ccc;
    border-radius: 8px;
    padding: 12px;
}

.error-message {
    background: #ffe6e6;
    color: #c0392b;
    padding: 15px;
    border-radius: 5px;
}

/* Footer */
.dash-footer {
    font-size: 12px;
    color: #666;
    padding: 0 30px 20px;
}

/* Side panel: units to ship by product */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
}

.sidebar-overlay.active {
    display: block;
}

.items-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    transform: translateX(100%);
    visibility: hidden;
    width: min(560px, 100%);
    height: 100%;
    background: white;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    transition: transform 0.3s ease, visibility 0.3s;
    overflow-y: auto;
}

.items-sidebar.active {
    transform: translateX(0);
    visibility: visible;
}

.sidebar-header,
.modal-header {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 1;
}

.sidebar-header h3 {
    font-size: 18px;
}

.sidebar-close-btn,
.modal-close-btn {
    flex: 0 0 auto;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 24px;
    line-height: 1;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
}

.sidebar-close-btn:hover,
.modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

.sidebar-content {
    padding: 16px 20px;
}

/* Order detail modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 8px;
    width: 100%;
    max-width: 820px;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-header {
    border-radius: 8px 8px 0 0;
}

.modal-header h2 {
    font-size: 20px;
}

.modal-body {
    padding: 18px 20px 22px;
}

.modal-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px 18px;
    padding: 14px;
    background: #f5f5f5;
    border-radius: 8px;
}

.modal-info-item {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.modal-info-label {
    font-size: 11px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 3px;
    font-weight: 600;
}

.modal-info-value {
    font-size: 16px;
    color: #1e3c72;
    font-weight: 700;
}

.modal-section-title {
    font-size: 16px;
    color: #1e3c72;
    margin: 18px 0 8px;
    padding-bottom: 6px;
    border-bottom: 2px solid #2a5298;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .dashboard-header { padding: 10px 16px; }
    .tab-menu { padding: 0 8px; }
    .tab-content { padding: 16px; }
    .dash-footer { padding: 0 16px 16px; }
    .tab-btn { padding: 11px 12px; font-size: 14px; }
    .demo-intro { padding: 12px 16px; }
}

@media (max-width: 600px) {
    .app-name { font-size: 17px; }
    .user-info { font-size: 12px; }
    .tab-pane h2 { font-size: 19px; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .stat-card { padding: 11px 12px; }
    .stat-title { font-size: 11px; }
    .stat-value { font-size: 21px; }
    .stat-sub { font-size: 12px; }
    .details-section { padding: 12px; }
    table { font-size: 13px; min-width: 560px; }
    .modal-content table, .items-sidebar table { min-width: 460px; }
    .cell-sub { white-space: nowrap; }
    .table-wrap.compact table { min-width: 0; }
    .table-wrap.compact .cell-sub { white-space: normal; }
    table th, table td { padding: 7px 8px; }
    .filters label { flex: 1 1 140px; }
    .filters input[type="search"], .filters select { width: 100%; }
    .chart-container { height: 260px; }
    .demo-title { font-size: 16px; }
    .demo-title-sub { font-size: 13px; }
    .demo-question, .demo-try { font-size: 13px; }
}
