/* Dark Liberty-style theme to mimic the desktop pharmacy software UI from the PDF.
   Reference: "Shipping Integration with Liberty Software.pdf" page 1 screenshot. */

:root {
    --bg-app: #2d2d2d;
    --bg-panel: #3a3a3a;
    --bg-input: #4a4a4a;
    --bg-input-focus: #555;
    --bg-button: #5a5a5a;
    --bg-button-primary: #f7941e;
    --bg-button-primary-hover: #ffa84d;
    --bg-grid-header: #4a4a4a;
    --bg-grid-row: #3a3a3a;
    --bg-grid-row-alt: #424242;
    --bg-titlebar: #1f1f1f;
    --fg-default: #e8e8e8;
    --fg-muted: #b8b8b8;
    --fg-label: #c8c8c8;
    --border-panel: #1a1a1a;
    --border-input: #6a6a6a;
    --border-group: #5a5a5a;
    --accent: #f7941e;
    --link: #6cb9f1;
}

html, body {
    background: var(--bg-app);
    color: var(--fg-default);
    font-family: "Segoe UI", Tahoma, "Helvetica Neue", Arial, sans-serif;
    font-size: 13px;
    margin: 0;
    padding: 0;
    height: 100%;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: #9ed1f8; text-decoration: underline; }

/* Top app bar — mimics the Chrome window chrome from the PDF screenshot */
.app-bar {
    background: var(--bg-titlebar);
    border-bottom: 1px solid var(--border-panel);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.app-bar .brand {
    font-weight: 600;
    font-size: 14px;
    color: var(--fg-default);
}
.app-bar .brand-tag {
    font-size: 11px;
    color: var(--fg-muted);
    background: #3a3a3a;
    padding: 2px 6px;
    border-radius: 3px;
}
.app-bar .nav-link {
    color: var(--fg-muted);
    padding: 4px 10px;
    border-radius: 3px;
}
.app-bar .nav-link:hover { background: #3a3a3a; color: var(--fg-default); text-decoration: none; }
.app-bar .nav-link.active { color: var(--fg-default); background: var(--bg-panel); }
.app-bar .spacer { flex: 1; }

/* Window-style panel matching the "Create Shipping Label" dialog from the PDF */
.window-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-panel);
    border-radius: 4px;
    margin: 16px auto;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
    max-width: 1200px;
}
.window-titlebar {
    background: var(--bg-titlebar);
    color: var(--fg-default);
    padding: 8px 14px;
    border-radius: 4px 4px 0 0;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--border-panel);
    font-weight: 500;
}
.window-titlebar .icon-circle {
    display: inline-block;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--accent);
}
.window-titlebar .close {
    margin-left: auto;
    color: var(--fg-muted);
    cursor: pointer;
    font-weight: 400;
}
.window-body {
    padding: 12px;
}

/* Top action row of the Create Shipping Label window (New / Find / Provider) */
.top-action-row {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 6px 4px 12px 4px;
}
.top-action-row label {
    color: var(--fg-label);
}
.top-action-row .grow { flex: 1; }

/* Group panel — the boxed sections labeled "Ship From", "Ship To", "Package Settings" */
.group-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-group);
    border-radius: 3px;
    padding: 10px 12px;
}
.group-panel-title {
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    text-transform: none;
    margin: -18px 0 6px 0;
    background: var(--bg-panel);
    display: inline-block;
    padding: 0 6px;
}
.group-panel.titled {
    margin-top: 14px;
    position: relative;
}
.group-panel.titled .group-panel-title {
    position: absolute;
    top: -8px;
    left: 10px;
    background: var(--bg-panel);
    margin: 0;
    padding: 0 6px;
}

/* Form layout — labels on the left, inputs on the right, like a desktop app */
.form-row {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    gap: 8px;
}
.form-row label {
    color: var(--fg-label);
    text-align: right;
    flex: 0 0 105px;
    font-size: 12px;
}
.form-row .input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
}
.form-row .pair {
    display: flex;
    gap: 6px;
    align-items: center;
}
.form-row .pair input { width: 60px; }
.form-row .pair input:first-child { flex: 1; }

/* When both inputs in the pair should be equal width (e.g. window From/To
   datetime-local pickers), use .pair.pair-equal to override the default
   "first input flexes, others narrow" behaviour. */
.form-row .pair-equal { width: 100%; }
.form-row .pair-equal input,
.form-row .pair-equal input:first-child { flex: 1 1 0; width: auto; min-width: 0; }

input.form-control,
select.form-select,
textarea.form-control {
    background: var(--bg-input);
    color: var(--fg-default);
    border: 1px solid var(--border-input);
    border-radius: 2px;
    padding: 4px 6px;
    font-size: 12px;
    line-height: 1.4;
}
input.form-control:focus,
select.form-select:focus,
textarea.form-control:focus {
    background: var(--bg-input-focus);
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 1px var(--accent);
}
input[type="checkbox"] {
    accent-color: var(--accent);
    width: 14px; height: 14px;
    margin-right: 4px;
    vertical-align: middle;
}

button.btn,
.btn {
    background: var(--bg-button);
    color: var(--fg-default);
    border: 1px solid var(--border-input);
    border-radius: 2px;
    padding: 4px 12px;
    font-size: 12px;
    cursor: pointer;
}
button.btn:hover,
.btn:hover { background: #6a6a6a; }
button.btn-primary,
.btn-primary {
    background: var(--bg-button-primary);
    color: #1a1a1a;
    border-color: var(--bg-button-primary);
    font-weight: 500;
}
button.btn-primary:hover,
.btn-primary:hover { background: var(--bg-button-primary-hover); border-color: var(--bg-button-primary-hover); }

/* Scripts grid */
.scripts-grid {
    width: 100%;
    background: var(--bg-grid-row);
    border-collapse: collapse;
    margin-bottom: 8px;
    border: 1px solid var(--border-input);
}
.scripts-grid th {
    background: var(--bg-grid-header);
    color: var(--fg-default);
    padding: 6px 8px;
    text-align: left;
    font-size: 12px;
    font-weight: 500;
    border-bottom: 1px solid var(--border-panel);
}
.scripts-grid td {
    padding: 5px 8px;
    border-bottom: 1px solid #2d2d2d;
    font-size: 12px;
}
.scripts-grid tr:nth-child(even) td { background: var(--bg-grid-row-alt); }
.scripts-grid tr.empty td {
    color: var(--fg-muted);
    text-align: center;
    padding: 18px;
    font-style: italic;
}

/* Process Order area at the bottom */
.process-bar {
    margin-top: 16px;
    padding-top: 10px;
    border-top: 1px solid var(--border-input);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Activity timeline */
.timeline-row {
    display: flex;
    gap: 12px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-input);
    font-size: 12px;
    align-items: flex-start;
}
.timeline-row:hover { background: rgba(247, 148, 30, 0.06); }
.timeline-time {
    color: var(--fg-muted);
    flex: 0 0 130px;
    font-family: "Consolas", monospace;
    font-size: 11px;
}
.timeline-tag {
    flex: 0 0 90px;
    text-align: center;
    border-radius: 2px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.timeline-tag.outbound { background: #2c5d2c; color: #c8f0c8; }
.timeline-tag.inbound { background: #5d4825; color: #f0d6a8; }
.timeline-tag.error { background: #6e2a2a; color: #f0c8c8; }
.timeline-message { flex: 1; }
.timeline-message .meta {
    color: var(--fg-muted);
    font-size: 11px;
    margin-top: 2px;
}

/* Alerts */
.alert {
    padding: 10px 14px;
    border-radius: 3px;
    margin: 10px 0;
    font-size: 12px;
}
.alert-success { background: #2c5d2c; color: #d8f0d8; border: 1px solid #3a7a3a; }
.alert-danger { background: #6e2a2a; color: #f0d8d8; border: 1px solid #903030; }
.alert-info { background: #25496e; color: #d6e8f0; border: 1px solid #366890; }

/* Status pills */
.pill {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.pill-draft { background: #5a5a5a; color: var(--fg-default); }
.pill-sent { background: #25496e; color: #d6e8f0; }
.pill-accepted { background: #2c5d2c; color: #d8f0d8; }
.pill-rejected { background: #6e2a2a; color: #f0d8d8; }
.pill-failed { background: #6e2a2a; color: #f0d8d8; }

/* Page section helpers */
.page-section { padding: 20px; max-width: 1200px; margin: 0 auto; }
.page-section h1 { font-weight: 500; font-size: 20px; margin-top: 0; }
.page-section h2 { font-weight: 500; font-size: 16px; color: var(--fg-label); border-bottom: 1px solid var(--border-input); padding-bottom: 4px; }

.kv-table { width: 100%; }
.kv-table td { padding: 4px 8px; font-size: 12px; }
.kv-table td:first-child { color: var(--fg-muted); width: 200px; }

footer.app-footer {
    color: var(--fg-muted);
    text-align: center;
    padding: 18px;
    font-size: 11px;
}
