/*
  CSS Design System for CryptoPortal
  Premium enterprise UI inspired by Palo Alto Networks colors and layout
*/

:root {
    /* PANW Brand Colors */
    --panw-orange: #f04c23;
    --panw-blue: #02a1d7;

    /* Light Theme (Primary) */
    --bg-main: #ffffff;
    --bg-header: #ffffff;
    --bg-panel: #ffffff;

    --text-main: #212529;
    --text-muted: #6c757d;

    --text-header: #212529;
    --text-header-muted: #6c757d;

    --border-light: #dee2e6;
    --border-header: #dee2e6;
    --border-focus: var(--panw-blue);

    --btn-primary-bg: #6c757d;
    --btn-primary-text: #ffffff;

    --input-bg: #ffffff;
    --input-border: #ced4da;
    --input-text: #495057;

    /* Layout */
    --header-height: 56px;
    --radius-sm: 0.25rem;
}

[data-theme="dark"] {
    --bg-main: #0F172A;
    --bg-header: #0F172A;
    --bg-panel: #1E293B;

    --text-main: #E2E8F0;
    --text-muted: #94A3B8;

    --text-header: #F8FAFC;
    --text-header-muted: #94A3B8;

    --border-light: #334155;
    --border-header: #1E293B;

    --input-bg: #1E293B;
    --input-border: #334155;
    --input-text: #E2E8F0;
}

/* Dark mode: keep result/cert boxes readable */
[data-theme="dark"] .result-block textarea,
[data-theme="dark"] .cert-input-area {
    background-color: #1E293B;
    color: #E2E8F0;
    border-color: #334155;
}

[data-theme="dark"] .ocsp-result-col,
[data-theme="dark"] .ss-download-box {
    background-color: #1E293B;
    border-color: #334155;
    color: #E2E8F0;
}

[data-theme="dark"] .data-table td,
[data-theme="dark"] .data-table th {
    color: #E2E8F0;
    border-color: #334155;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Exact Native Bootstrap 5 Font Stack */
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Top Horizontal Header */
.top-header {
    height: var(--header-height);
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border-header);
    display: flex;
    align-items: center;
    padding: 0 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.brand-icon {
    color: var(--panw-orange);
    display: none;
    /* Hide icon to match simpler look unless requested */
}

/* Identical typography to original h1 class */
.brand h1 {
    font-size: 1.25rem;
    font-weight: 400;
    color: var(--text-header);
}

/* 1cm space to the right of the site logo */
.nav-menu {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: 38px;
    flex: 1;
}

.nav-item {
    background: transparent;
    border: none;
    color: var(--text-header-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.5rem 0;
    position: relative;
    text-decoration: none;
}

.nav-item:hover {
    color: var(--text-header);
}

.nav-item.active {
    color: rgba(0, 0, 0, .9);
    font-weight: 400;
}

[data-theme="dark"] .nav-item.active {
    color: #E2E8F0;
}

.nav-item.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: var(--panw-orange);
}

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

.icon-btn {
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-header);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.content-panel h2 {
    margin-bottom: 1rem;
}

/* Original In-line Control Form */
.inline-control-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    /* Reduced gap to match original closer elements */
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 1rem;
}

.btn-group {
    display: flex;
}

.btn-group-item {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-muted);
    padding: 0.25rem 0.5rem;
    /* Equivalent to btn-sm */
    font-size: 0.875rem;
    cursor: pointer;
    line-height: 1.5;
}

.btn-group-item:first-child {
    border-top-left-radius: 0.2rem;
    border-bottom-left-radius: 0.2rem;
}

.btn-group-item:last-child {
    border-top-right-radius: 0.2rem;
    border-bottom-right-radius: 0.2rem;
}

.btn-group-item:not(:first-child) {
    border-left: none;
}

.btn-group-item.active {
    background: var(--bg-main);
    color: var(--panw-blue);
    /* Retaining slight customized branding element, but default behavior */
    border-color: var(--border-light);
}

.dynamic-inputs-wrapper {
    display: flex;
    align-items: center;
}

.dynamic-inputs {
    display: none;
    align-items: center;
    gap: 10px;
}

.dynamic-inputs.active {
    display: flex;
}

.dynamic-inputs input {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 0.2rem;
    padding: 0.25rem 0.5rem;
    color: var(--input-text);
    font-size: 0.875rem;
    line-height: 1.5;
    flex: 1;
    min-width: 150px;
    transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}

.input-inline {
    display: flex;
    align-items: center;
}

.input-inline input {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 0.2rem;
    padding: 0.25rem 0.5rem;
    color: var(--input-text);
    font-size: 0.875rem;
    line-height: 1.5;
    width: 160px;
    /* Adjusting width to feel more like original */
}

/* Simulating standard form-control-sm placeholder sizes */
.dynamic-inputs input::placeholder,
.input-inline input::placeholder {
    color: #6c757d;
    font-style: italic;
    font-weight: 400;
}

.dynamic-inputs input:focus,
.input-inline input:focus {
    outline: none;
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.select-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.select-group label {
    font-size: 0.875rem;
    color: var(--text-main);
    font-weight: 400;
}

.select-group select {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 0.2rem;
    padding: 0.25rem 0.5rem;
    color: var(--input-text);
    font-size: 0.875rem;
    line-height: 1.5;
    cursor: pointer;
}

/* Mirroring btn-sm btn-outline-secondary */
.btn-outline-primary {
    background: transparent;
    border: 1px solid var(--input-border);
    color: var(--text-muted);
    padding: 0.25rem 0.5rem;
    border-radius: 0.2rem;
    cursor: pointer;
    font-size: 0.875rem;
    line-height: 1.5;
    margin-left: 5px;
}

.btn-outline-primary:hover {
    background: var(--border-light);
    color: var(--text-main);
}


/* Result Display Blocks */
.result-display {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.result-display.row-layout {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 1rem;
}

@media (min-width: 768px) {
    .result-display.row-layout {
        flex-wrap: nowrap;
    }
}

.result-block {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1 1 300px;
    min-width: 0;
}

/* Self-signed 2×2 grid */
.ss-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.ss-download-box {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: var(--radius-sm);
    background: #fafafa;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.ss-download-btn {
    width: 100%;
    padding: 10px 16px;
    background: #0070f3;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.ss-download-btn:hover {
    background: #005bb5;
}

.btn-primary {
    padding: 8px 20px;
    background: #0070f3;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-primary:hover {
    background: #005bb5;
}


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

.result-block label {
    font-size: 1rem;
    color: var(--text-main);
    font-weight: 400;
}

.copy-btn {
    border: none;
    color: var(--text-muted);
    padding: 4px;
    height: 28px;
    width: 28px;
}

.copy-btn:hover {
    color: var(--panw-blue);
    background: transparent;
}

.result-block textarea {
    width: 100%;
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: var(--radius-sm);
    color: var(--input-text);
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.875rem;
    padding: 10px;
    resize: vertical;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.result-block textarea::placeholder {
    color: #6c757d;
}

.hidden {
    display: none !important;
}

/* Views Management */
.tool-view {
    display: none;
}

.tool-view.active {
    display: block;
}

/* Certificate Validation Specifics */
.cert-input-area {
    width: 100%;
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: var(--radius-sm);
    color: var(--input-text);
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.875rem;
    padding: 10px;
    resize: vertical;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.cert-input-area::placeholder {
    color: #6c757d;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-style: italic;
    font-weight: 400;
}

.cert-input-area:focus {
    outline: none;
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* OCSP side-by-side layout */
.ocsp-layout {
    display: flex;
    gap: 1.5rem;
    align-items: stretch;
    /* both cols same height */
    flex-wrap: wrap;
    min-height: 280px;
}

.ocsp-input-col {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.ocsp-input-col .cert-input-area {
    flex: 1;
    /* textarea grows to fill all remaining col height */
    resize: none;
    /* prevent manual resize breaking the layout */
}

.ocsp-input-col .btn-outline-primary {
    width: 100%;
    /* full width of the input column */
    margin: 0.5rem 0 0;
    box-sizing: border-box;
}

.ocsp-result-col {
    flex: 1 1 0;
    border: 1px solid #ddd;
    border-radius: var(--radius-sm);
    padding: 1rem;
    box-sizing: border-box;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    background-color: #fafafa;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.875rem;
}

.data-table th,
.data-table td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
}

.data-table th {
    color: var(--text-main);
    font-weight: 600;
}

.data-table td {
    color: var(--text-muted);
}

.data-table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] .data-table tbody tr:hover {
    background-color: #0F172A;
}