/* ============================================================
   VenTek Temp TMS - Stylesheet
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
        Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    background: #f5f6fa;
}

a {
    color: #3498db;
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* --- Sidebar --- */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 220px;
    height: 100vh;
    /* Cap at viewport height so the sidebar never pushes past the
       bottom of the window, even with many catalog items, a long
       env badge, or many nav sections. The inner `.sidebar-nav`
       scrolls internally when its items exceed available space. */
    overflow: hidden;
    background: #2c3e50;
    color: #ecf0f1;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid #3d566e;
}
.sidebar-header h2 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.sidebar-clock {
    margin-top: 8px;
    font-size: 12px;
    font-weight: normal;
    color: #8e9eaf;
    font-family: "SF Mono", "Consolas", "Monaco", monospace;
    line-height: 1.6;
}
.clock-row {
    display: flex;
    justify-content: space-between;
    padding: 0 4px;
}
.clock-label {
    color: #8e9eaf;
    font-size: 12px;
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Env badge in sidebar — sits below the clock. Width is constrained to
   match clock-row width (padded 0 4px) so the badge visually aligns
   with the left edge of "UTC"/"Local" and the right edge of the time
   text. */
.sidebar-env {
    margin-top: 10px;
    padding: 0 4px;
    display: flex;
    justify-content: stretch;
}
.sidebar-env .env-badge {
    width: 100%;
    justify-content: center;
    box-sizing: border-box;
    padding: 4px 10px;
}

.sidebar-nav {
    list-style: none;
    flex: 1;
    /* Scroll the nav list internally when its items overflow the
       available space (short viewports, many catalog items). Without
       `min-height: 0` the flex child refuses to shrink below its
       content size, which pushes the footer off-screen. */
    overflow-y: auto;
    min-height: 0;
    padding: 6px 0;
}
.sidebar-nav li a {
    display: block;
    /* Tightened vertical padding for ~22% less space per nav item
       vs. the original 12px (total row ≈ 35.5 px from the ≈ 45 px
       original). Tried 7 px first but the rows felt squished;
       9 px gives breathable rhythm while still fitting the full
       nav on small laptop screens without the footer being pushed
       below the fold. Horizontal padding unchanged so indent and
       alignment stay put. */
    padding: 9px 20px;
    line-height: 1.25;
    color: #bdc3c7;
    font-size: 14px;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
}
.sidebar-nav li a:hover {
    background: #34495e;
    color: #fff;
    text-decoration: none;
}
.sidebar-nav li a.active {
    background: #3498db;
    color: #fff;
}

.sidebar-nav li.nav-section {
    /* Same ~30% vertical tightening as leaf items — keeps the
       section-header rhythm consistent with the shorter rows. */
    padding: 9px 16px 3px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #acb7c3;
    margin-top: 4px;
    border-top: 1px solid #3d566e;
}
.sidebar-nav li.nav-section:first-of-type {
    border-top: none;
    margin-top: 0;
}
/* Clickable section headers (Dashboard) — must override generic li a */
.sidebar-nav li.nav-section.nav-section-link a {
    display: block;
    color: #acb7c3;
    text-decoration: none;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 0;
    background: none;
    transition: color 0.15s;
}
.sidebar-nav li.nav-section.nav-section-link a:hover {
    color: #fff;
    background: none;
}
.sidebar-nav li.nav-section.nav-section-link a.active {
    color: #fff;
    background: none;
}
/* Indent leaf items under section headers */
.sidebar-nav li.nav-section ~ li:not(.nav-section) > a {
    padding-left: 32px;
    font-size: 13px;
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid #3d566e;
}
.sidebar-user {
    display: block;
    font-size: 12px;
    color: #ecf0f1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 4px;
}
.sidebar-logout {
    background: none;
    border: none;
    padding: 0;
    color: #bdc3c7;
    font-size: 12px;
    cursor: pointer;
    text-align: left;
}
.sidebar-logout:hover {
    color: #e74c3c;
}
.sidebar-version {
    display: block;
    font-size: 10px;
    color: #7f8c8d;
    margin-top: 10px;
}
.sidebar-footer a {
    color: #bdc3c7;
    font-size: 13px;
    text-decoration: none;
}
.sidebar-footer a:hover {
    color: #e74c3c;
}

/* --- Main Content --- */
#main {
    margin-left: 220px;
    min-height: 100vh;
}

#topbar {
    background: #fff;
    padding: 15px 25px;
    border-bottom: 1px solid #ddd;
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 20px;
}
.topbar-heading-group {
    display: flex;
    align-items: center;
    gap: 14px;
}
#topbar h1 {
    font-size: 20px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

/* --- Env badge (topbar) ---
   dev  = green (canonical dev droplet)
   prod = orange (canonical prod droplet)
   unknown = red (ambiguous or local)
*/
.env-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    border: 1px solid transparent;
    cursor: help;
}
.env-badge-dev     { background: #d4edda; color: #155724; border-color: #a5d6b1; }
.env-badge-prod    { background: #ffe0b2; color: #8a4b00; border-color: #f0b97a; }
.env-badge-unknown { background: #f8d7da; color: #721c24; border-color: #e5a4aa; }
.env-badge-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: currentColor;
    display: inline-block;
}
.env-badge-icon {
    font-size: 14px;
    line-height: 1;
    display: inline-block;
}
.env-badge-unknown {
    /* Heavier visual weight for the unknown state so it actually
       registers as a warning at a glance. */
    font-size: 13px;
    padding: 6px 16px;
    border-width: 2px;
}

#content {
    padding: 20px 25px;
}

/* --- Cards --- */
.card {
    background: #fff;
    border: 1px solid #e1e4e8;
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 20px;
}
.card-late {
    border-left: 4px solid #e6ac00;
    background: #fffbe6;
}
.card ul, .card ol {
    padding-left: 1.3em;
    margin: 6px 0 10px 0;
}
.card li {
    margin-bottom: 5px;
    line-height: 1.5;
}
.card-header {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
    color: #2c3e50;
}

.stat-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
}
.stat-card {
    background: #fff;
    border: 1px solid #e1e4e8;
    border-radius: 4px;
    padding: 18px 22px;
    min-width: 140px;
    flex: 1;
    text-align: center;
}
.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #2c3e50;
}
.stat-card .stat-label {
    font-size: 12px;
    color: #7f8c8d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* Dashboard hero: bigger cards, status-colored top border, emphasized value */
.stat-cards-hero {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.stat-cards-hero .stat-card {
    padding: 22px 20px;
    border-top: 4px solid #ccc;
    color: inherit;
    text-decoration: none;
    transition: transform 0.1s, box-shadow 0.1s;
}
/* When the card is a link (clickable filter), subtle hover affordance. */
a.stat-card:hover {
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.stat-cards-hero .stat-card .stat-value {
    font-size: 42px;
    line-height: 1;
}
.stat-cards-hero .stat-card .stat-label {
    margin-top: 10px;
    font-size: 13px;
    font-weight: 600;
}
.stat-cards-hero .stat-card.zero .stat-value { color: #b8bec6; }
.stat-cards-hero .stat-card-new           { border-top-color: #7f8c8d; }
.stat-cards-hero .stat-card-provisioning  { border-top-color: #f0ad4e; }
.stat-cards-hero .stat-card-ready         { border-top-color: #17a2b8; }
.stat-cards-hero .stat-card-active        { border-top-color: #28a745; }
.stat-cards-hero .stat-card-error         { border-top-color: #dc3545; }
.stat-cards-hero .stat-card-decommissioned{ border-top-color: #6c757d; }
.stat-cards-hero .stat-card-late          { border-top-color: #e6ac00; }

/* --- Tables --- */
table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}
thead th {
    background: #f8f9fa;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: #555;
    border-bottom: 2px solid #dee2e6;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    font-size: 13px;
}
tbody tr:nth-child(even) {
    background: #fafbfc;
}
tbody tr:hover {
    background: #f0f4f8;
}
tbody tr.clickable {
    cursor: pointer;
}
tbody tr.row-late {
    background-color: #fffbe6;
}
tbody tr.row-late:hover {
    background-color: #fff3cd;
}

.table-empty {
    text-align: center;
    padding: 30px;
    color: #999;
    font-style: italic;
}

/* --- Status Badges --- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.badge-active      { background: #d4edda; color: #155724; }
.badge-error       { background: #f8d7da; color: #721c24; }
.badge-unknown     { background: #e2e3e5; color: #555; }
.badge-assigned    { background: #cce5ff; color: #004085; }
.badge-provisioning { background: #fff3cd; color: #856404; }
.badge-inactive    { background: #fde8d0; color: #945a20; }
.badge-decommissioned { background: #d6d8db; color: #3d4144; }
.badge-unassigned  { background: #e2e3e5; color: #555; }
.badge-late        { background: #fff3cd; color: #856404; }
.badge-new         { background: #e2e3e5; color: #555; }
.badge-ready       { background: #d1ecf1; color: #0c5460; }

/* --- Buttons --- */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border: none;
    border-radius: 3px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
    line-height: 1.4;
    vertical-align: middle;
}
.btn:hover {
    opacity: 0.9;
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn + .btn {
    margin-left: 6px;
}

.btn-primary   { background: #3498db; color: #fff; }
.btn-danger    { background: #e74c3c; color: #fff; }
.btn-success   { background: #27ae60; color: #fff; }
.btn-secondary { background: #95a5a6; color: #fff; }
.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}
.btn-block {
    display: block;
    width: 100%;
}

.btn-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 15px;
}
.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 13px;
    color: #555;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.15);
}
.form-group textarea {
    min-height: 120px;
    resize: vertical;
    font-family: "Consolas", "Monaco", "Courier New", monospace;
}

.form-hint {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: #7f8c8d;
    line-height: 1.4;
}
.form-row {
    display: flex;
    gap: 20px;
}
.ftp-warning {
    margin-top: 12px;
    padding: 10px 14px;
    background: #c0392b;
    color: #fff;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
}

.form-inline {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.form-inline .form-group {
    margin-bottom: 0;
}

/* --- Filters / Toolbar --- */
.toolbar {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 15px;
    padding: 12px 15px;
    background: #fff;
    border: 1px solid #e1e4e8;
    border-radius: 4px;
}
.toolbar .form-group {
    margin-bottom: 0;
    min-width: 150px;
}
.toolbar input,
.toolbar select {
    padding: 6px 8px;
    font-size: 13px;
}

/* --- Alerts --- */
.alert {
    padding: 12px 16px;
    border-radius: 3px;
    margin-bottom: 15px;
    font-size: 13px;
    border: 1px solid transparent;
}
.alert-error   { background: #f8d7da; color: #721c24; border-color: #f5c6cb; }
.alert-warning { background: #fff3cd; color: #856404; border-color: #ffeeba; }
.alert-info    { background: #d1ecf1; color: #0c5460; border-color: #bee5eb; }
.alert-success { background: #d4edda; color: #155724; border-color: #c3e6cb; }

/* --- Toast --- */
#toast-container {
    position: fixed;
    top: 70px;
    right: 25px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 12px 20px;
    border-radius: 4px;
    font-size: 13px;
    min-width: 250px;
    max-width: 400px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.15);
    animation: toast-in 0.25s ease-out;
}
.toast-success { background: #27ae60; color: #fff; }
.toast-error   { background: #e74c3c; color: #fff; }
.toast-info    { background: #3498db; color: #fff; }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(30px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal {
    background: #fff;
    border-radius: 5px;
    min-width: 360px;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
}
.modal-header h3 {
    font-size: 16px;
    color: #2c3e50;
}
.modal-body {
    padding: 20px;
    font-size: 14px;
    color: #555;
}
.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* --- Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 15px;
    padding: 10px 0;
}
.pagination button {
    padding: 6px 12px;
    border: 1px solid #ddd;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    border-radius: 3px;
    color: #333;
}
.pagination button:hover:not(:disabled) {
    background: #f0f4f8;
}
.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.pagination button.active {
    background: #3498db;
    color: #fff;
    border-color: #3498db;
}
.pagination .page-info {
    font-size: 13px;
    color: #777;
    margin: 0 10px;
}

/* --- Loading Spinner --- */
.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}
.loading-spinner::after {
    content: "";
    width: 32px;
    height: 32px;
    border: 3px solid #e1e4e8;
    border-top-color: #3498db;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* --- Login Page --- */
.login-body {
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-card {
    background: #fff;
    padding: 40px 35px;
    border-radius: 6px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 380px;
}
.login-title {
    text-align: center;
    color: #2c3e50;
    font-size: 24px;
    margin-bottom: 4px;
}
.login-subtitle {
    text-align: center;
    color: #999;
    font-size: 13px;
    margin-bottom: 25px;
}
.login-notice {
    text-align: center;
    color: #888;
    font-size: 11px;
    margin-top: 15px;
}
.login-card .form-group {
    margin-bottom: 18px;
}
.login-card .btn {
    margin-top: 8px;
    padding: 10px;
    font-size: 15px;
}

/* --- Detail Page Info --- */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 15px;
}
.info-item label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    color: #999;
    letter-spacing: 0.3px;
    margin-bottom: 2px;
}
.info-item span {
    font-size: 14px;
    color: #333;
    font-weight: 500;
}

/* --- Section spacing --- */
.section {
    margin-top: 25px;
}
.section-title {
    font-size: 15px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #eee;
}

/* --- Checkboxes --- */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: normal;
    font-size: 13px;
    cursor: pointer;
}
.checkbox-group input[type="checkbox"] {
    width: auto;
}

/* --- Getting Started Flow --- */
.getting-started {
    border: 1px solid #d5e8f5;
    border-radius: 6px;
    margin-bottom: 20px;
    background: #f8fbfe;
}
.getting-started-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
}
.getting-started-toggle h3 {
    margin: 0;
    font-size: 14px;
    color: #2c3e50;
    font-weight: 600;
}
.getting-started-toggle .gs-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.getting-started-toggle .gs-chevron {
    color: #999;
    font-size: 12px;
    transition: transform 0.2s;
}
.getting-started.collapsed .gs-chevron {
    transform: rotate(-90deg);
}
.getting-started.collapsed .getting-started-body {
    display: none;
}
.getting-started-body {
    padding: 0 16px 16px;
}
.gs-flow {
    display: flex;
    gap: 0;
    align-items: stretch;
}
.gs-step {
    flex: 1;
    background: #fff;
    border: 1px solid #dce6ef;
    border-radius: 5px;
    padding: 14px 14px 12px;
    position: relative;
}
.gs-step-num {
    display: inline-block;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #3498db;
    color: #fff;
    text-align: center;
    line-height: 22px;
    font-size: 12px;
    font-weight: 700;
    margin-right: 6px;
}
.gs-step h4 {
    display: inline;
    font-size: 13px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}
.gs-step p {
    margin: 8px 0 0;
    font-size: 12px;
    line-height: 1.5;
    color: #555;
}
.gs-arrow {
    display: flex;
    align-items: center;
    padding: 0 6px;
    font-size: 18px;
    color: #bbb;
}
.gs-guide-link {
    font-size: 12px;
    color: #3498db;
    text-decoration: none;
    white-space: nowrap;
}
.gs-guide-link:hover {
    text-decoration: underline;
}

/* --- Three-slot panel (terminal detail) --- */
.slots-table {
    margin-bottom: 0;
}
.slots-table .slot-row th {
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    color: #666;
}
.slots-table .slot-row-active th { color: #117a8b; }
.slots-table .slot-row-staged th { color: #b56f00; }
.slots-table .slot-row-previous th { color: #888; }
.slots-table .slot-match {
    background-color: #f0f9f0;
}
.slot-match-tag {
    display: inline-block;
    padding: 1px 8px;
    background: #d4edda;
    color: #155724;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.ready-gate-check-promote-ready {
    color: #117a8b;
}

/* --- Utility --- */
.text-muted { color: #999; }
.text-right { text-align: right; }
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }
.truncate {
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    vertical-align: middle;
}

/* --- Print styles --- */
@media print {
    #sidebar, #topbar, .btn-group, .no-print { display: none !important; }
    #main { margin-left: 0 !important; }
    #content { padding: 0 !important; }
    body { background: #fff !important; font-size: 12pt; }
    .card {
        border: 1px solid #ccc !important;
        border-radius: 0 !important;
        padding: 12pt !important;
        margin-bottom: 14pt !important;
        page-break-inside: avoid;
        background: #fff !important;
    }
    .card-late { border-left: 3pt solid #e6ac00 !important; background: #fffbe6 !important; }
    .card-header { font-size: 14pt !important; margin-bottom: 8pt !important; }
    a { color: inherit !important; text-decoration: none !important; }
    table { border-collapse: collapse; width: 100%; font-size: 12pt; }
    th, td { border: 1px solid #ccc; padding: 4pt 6pt; }
    thead { background: #f6f8fa !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    code { font-size: 12pt; }
}
