/* ============================================================================
   POSEIDON MK7 DIAGNOSTICS - Matching arenleishman.com / TrimixWhistle Style
   ============================================================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500&family=Lato:wght@300;400;600;700&display=swap');

/* CSS Variables */
:root {
    --navy: #0F2E3D;
    --navy-hover: #1a4a5e;
    --gold: #CA981A;
    --gold-light: rgba(202, 152, 26, 0.08);
    --gold-medium: rgba(202, 152, 26, 0.4);
    --white: #FFFFFF;
    --light-gray: #f1f3f5;
    --text-primary: rgba(0, 0, 0, 1.0);
    --text-secondary: rgba(0, 0, 0, 0.8);
    --text-muted: rgba(0, 0, 0, 0.6);
    --text-light: rgba(255, 255, 255, 0.8);
    --border-radius: 4px;
    --transition: 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--white);
    color: var(--text-primary);
    min-height: 100vh;
    font-size: 1.06rem;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 40px 20px;
}

/* Header */
header {
    background: var(--navy);
    padding: 14px 20px;
    margin-bottom: 32px;
}

header .header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.back-link {
    color: var(--gold);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: var(--transition);
}

.back-link:hover {
    color: var(--white);
}

.header-title {
    text-align: center;
    flex: 1;
}

.header-title h1 {
    color: var(--white);
    font-size: 1.5rem;
    font-weight: 600;
}

.header-title .subtitle {
    font-size: 0.9rem;
    font-weight: 300;
    color: var(--text-light);
    margin-top: 2px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.desktop-notice {
    width: 100%;
    background: rgba(202, 152, 26, 0.15);
    border: 1px solid var(--gold);
    border-radius: var(--border-radius);
    padding: 10px 16px;
    font-size: 0.85rem;
    color: var(--white);
    margin-top: 8px;
}

.desktop-notice strong {
    color: var(--gold);
}

.status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
    font-size: 0.9rem;
    color: var(--text-light);
}

.status::before {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status.disconnected::before {
    background-color: var(--text-light);
    opacity: 0.5;
}

.status.connecting::before {
    background-color: var(--gold);
    animation: pulse-dot 1.5s infinite;
}

.status.connected::before {
    background-color: #4ade80;
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
}

.status.error::before {
    background-color: #dc3545;
    animation: pulse-dot 1s infinite;
}

@keyframes pulse-dot {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

/* Buttons */
button {
    padding: 14px 28px;
    border: none;
    border-radius: var(--border-radius);
    font-family: 'Lato', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: var(--white);
    color: var(--navy);
    border: 2px solid var(--gold);
}

.btn-primary:hover:not(:disabled) {
    background: var(--gold);
    color: var(--navy);
}

.btn-secondary {
    background: var(--light-gray);
    color: var(--text-secondary);
}

.btn-secondary:hover:not(:disabled) {
    background: #e9ecef;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9rem;
    background: var(--white);
    color: var(--navy);
    border: 2px solid var(--gold);
}

.btn-small:hover:not(:disabled) {
    background: var(--gold);
    color: var(--navy);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Main Content */
main {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Chart Container */
.chart-container {
    background: var(--light-gray);
    border-radius: var(--border-radius);
    padding: 20px;
}

/* Info Panel */
.info-panel {
    background: var(--light-gray);
    border-radius: var(--border-radius);
    padding: 20px;
}

.info-panel h3 {
    color: var(--navy);
    margin-bottom: 16px;
    font-size: 1.1rem;
    font-weight: 600;
}

.value-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.device-info-grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.device-info-grid .value-item span {
    font-family: 'Fira Code', monospace;
    font-size: 0.95rem;
    word-break: break-all;
}

.value-item {
    background: var(--white);
    padding: 16px 20px;
    border-radius: var(--border-radius);
    border-left: 4px solid transparent;
}

.value-item.highlight {
    border-left-color: var(--gold);
    background: var(--gold-light);
}

.value-item label {
    display: block;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 400;
    margin-bottom: 4px;
}

.value-item span {
    display: block;
    color: var(--navy);
    font-family: 'Fira Code', monospace;
    font-size: 1.25rem;
    font-weight: 500;
}

/* Log Panel */
.log-panel {
    background: var(--light-gray);
    border-radius: var(--border-radius);
    padding: 20px;
}

.log-panel h3 {
    color: var(--navy);
    margin-bottom: 16px;
    font-size: 1.1rem;
    font-weight: 600;
}

#log-output {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 16px;
    max-height: 200px;
    overflow-y: auto;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
}

.log-entry {
    padding: 4px 0;
    border-bottom: 1px solid var(--light-gray);
    color: var(--text-secondary);
}

.log-entry:last-child {
    border-bottom: none;
}

.log-info {
    color: var(--navy);
}

.log-warn {
    color: var(--gold);
}

.log-error {
    color: #dc3545;
}

#log-output::-webkit-scrollbar {
    width: 8px;
}

#log-output::-webkit-scrollbar-track {
    background: var(--light-gray);
    border-radius: var(--border-radius);
}

#log-output::-webkit-scrollbar-thumb {
    background: var(--navy);
    border-radius: var(--border-radius);
}

#log-output::-webkit-scrollbar-thumb:hover {
    background: var(--navy-hover);
}

/* Collapsible Panel Styles */
.collapsible-panel {
    background: var(--light-gray);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
}

.collapsible-header:hover {
    background: rgba(0, 0, 0, 0.03);
}

.collapsible-header h3 {
    color: var(--navy);
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.collapse-icon {
    color: var(--navy);
    font-size: 0.9rem;
    transition: transform 0.3s ease;
}

.collapsible-panel.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.collapsible-content {
    padding: 0 20px 20px 20px;
    max-height: 800px;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.collapsible-panel.collapsed .collapsible-content {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
}

/* Registers Panel Styles */
.registers-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.register-count {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.registers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
    max-height: 600px;
    overflow-y: auto;
    padding-right: 8px;
}

.registers-grid::-webkit-scrollbar {
    width: 8px;
}

.registers-grid::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: var(--border-radius);
}

.registers-grid::-webkit-scrollbar-thumb {
    background: var(--navy);
    border-radius: var(--border-radius);
}

.register-item {
    background: var(--white);
    padding: 12px 16px;
    border-radius: var(--border-radius);
    border-left: 4px solid transparent;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.register-item.empty {
    border-left-color: transparent;
    opacity: 0.5;
}

.register-item.has-value {
    border-left-color: var(--gold);
    background: var(--gold-light);
}

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

.register-addr {
    font-family: 'Fira Code', monospace;
    font-weight: 500;
    color: var(--navy);
    font-size: 0.95rem;
}

.register-info {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    max-width: 150px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.register-values {
    display: flex;
    gap: 16px;
    align-items: center;
}

.register-hex {
    display: flex;
    align-items: center;
    gap: 8px;
}

.register-hex label {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 400;
}

.register-hex input {
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    background: var(--light-gray);
    border: 2px solid var(--light-gray);
    border-radius: var(--border-radius);
    color: var(--navy);
    padding: 6px 10px;
    width: 100px;
    text-transform: uppercase;
    transition: var(--transition);
}

.register-hex input:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.register-hex input:focus {
    outline: none;
    border-color: var(--gold);
}

.register-decimal {
    display: flex;
    align-items: center;
    gap: 8px;
}

.register-decimal label {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 400;
}

.register-decimal span {
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Footer */
footer {
    background: var(--navy);
    padding: 20px;
    text-align: center;
    margin-top: 30px;
}

footer p {
    color: var(--text-light);
    font-size: 0.85rem;
    font-weight: 300;
}

footer a {
    color: var(--gold);
    text-decoration: none;
}

footer a:hover {
    color: var(--white);
}

/* Responsive */
@media (max-width: 768px) {
    header {
        padding: 12px 16px;
    }

    header .header-content {
        flex-direction: column;
        text-align: center;
    }

    .back-link {
        order: -1;
    }

    .header-title h1 {
        font-size: 1.25rem;
    }

    .header-controls {
        justify-content: center;
    }

    .value-grid {
        grid-template-columns: 1fr;
    }

    .device-info-grid {
        grid-template-columns: 1fr;
    }

    .registers-grid {
        grid-template-columns: 1fr;
    }

    button {
        padding: 12px 20px;
        font-size: 0.95rem;
    }
}
