/* ==========================================================================
   Raspberry Pi Reference Page — Page-Specific Styles
   Builds on top of ../../css/hub.css (shared parent stylesheet)
   ========================================================================== */

/* ---------- Page Layout ---------- */
.rpi-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px 60px;
}

/* ==========================================================================
   Tab System
   ========================================================================== */
.rpi-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 32px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.rpi-tabs::-webkit-scrollbar {
    display: none;
}

.rpi-tab {
    flex-shrink: 0;
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #64748b;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.2s, border-color 0.2s;
    font-family: inherit;
}

.rpi-tab:hover {
    color: #1e293b;
}

.rpi-tab.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
}

.rpi-tab-content {
    display: none;
}

.rpi-tab-content.active {
    display: block;
}

/* ==========================================================================
   Stat Grid (4-col -> 2-col responsive)
   ========================================================================== */
.rpi-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 40px;
}

.rpi-stat {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 20px 24px;
    text-align: center;
}

.rpi-stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #1e293b;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.rpi-stat-label {
    font-size: 0.8rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 4px;
    font-weight: 600;
}

.rpi-stat-sub {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 2px;
}

/* Coloured top border per stat */
.rpi-stat[data-color="blue"]   { border-top: 3px solid #3b82f6; }
.rpi-stat[data-color="green"]  { border-top: 3px solid #22c55e; }
.rpi-stat[data-color="amber"]  { border-top: 3px solid #f59e0b; }
.rpi-stat[data-color="purple"] { border-top: 3px solid #8b5cf6; }

@media (max-width: 900px) {
    .rpi-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ==========================================================================
   Section Headings
   ========================================================================== */
.rpi-section {
    margin-bottom: 40px;
}

.rpi-section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    margin-top: 0;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e2e8f0;
}

/* ==========================================================================
   Data Tables
   ========================================================================== */
.rpi-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 24px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.rpi-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.rpi-table th {
    background: #f8fafc;
    color: #1e293b;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 10px 14px;
    text-align: left;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

.rpi-table td {
    padding: 10px 14px;
    color: #475569;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: top;
}

.rpi-table tbody tr:last-child td {
    border-bottom: none;
}

/* Striped rows */
.rpi-table tbody tr:nth-child(even) {
    background: #f8fafc;
}

.rpi-table tbody tr:hover {
    background: #f1f5f9;
}

.rpi-table td strong {
    color: #1e293b;
}

/* Inline code in tables */
.rpi-table code,
.rpi-config-card code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.78rem;
    font-family: "SF Mono", "Fira Code", "Consolas", monospace;
    color: #334155;
}

/* ==========================================================================
   Sortable Table — Compare Tab
   ========================================================================== */
.rpi-sortable th[data-sort] {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 22px;
}

.rpi-sortable th[data-sort]:hover {
    background: #eef2f7;
}

.rpi-sortable th[data-sort]::after {
    content: '\2195';
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: #94a3b8;
    transition: color 0.15s;
}

.rpi-sortable th.rpi-sort-asc::after {
    content: '\2191';
    color: #3b82f6;
}

.rpi-sortable th.rpi-sort-desc::after {
    content: '\2193';
    color: #3b82f6;
}

/* Power columns highlighted */
.rpi-col-power {
    background: rgba(239, 68, 68, 0.04);
}

.rpi-sortable th.rpi-col-power {
    background: rgba(239, 68, 68, 0.08);
    color: #b91c1c;
}

.rpi-sortable th.rpi-col-power:hover {
    background: rgba(239, 68, 68, 0.14);
}

[data-theme="dark"] .rpi-sortable th[data-sort]:hover {
    background: #334155;
}

[data-theme="dark"] .rpi-sortable th.rpi-col-power {
    background: rgba(239, 68, 68, 0.12);
    color: #fca5a5;
}

[data-theme="dark"] .rpi-sortable th.rpi-col-power:hover {
    background: rgba(239, 68, 68, 0.20);
}

[data-theme="dark"] .rpi-col-power {
    background: rgba(239, 68, 68, 0.06);
}

/* ==========================================================================
   Info Cards (accessory / product cards)
   ========================================================================== */
.rpi-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 20px;
}

.rpi-card-title {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 8px;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rpi-card-desc {
    font-size: 0.85rem;
    color: #64748b;
    line-height: 1.55;
}

/* ==========================================================================
   Badges (status pills)
   ========================================================================== */
.rpi-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: 9999px;
    line-height: 1.5;
    white-space: nowrap;
}

.rpi-badge-green {
    background-color: #dcfce7;
    color: #166534;
}

.rpi-badge-amber {
    background-color: #fef3c7;
    color: #92400e;
}

.rpi-badge-red {
    background-color: #fee2e2;
    color: #991b1b;
}

.rpi-badge-blue {
    background-color: #dbeafe;
    color: #1e40af;
}

.rpi-badge-slate {
    background-color: #f1f5f9;
    color: #475569;
}

/* ==========================================================================
   Note / Warning Callout Boxes
   ========================================================================== */
.rpi-note {
    background: #eff6ff;
    border-left: 4px solid #3b82f6;
    border-radius: 0 8px 8px 0;
    padding: 14px 18px;
    font-size: 0.85rem;
    color: #1e40af;
    line-height: 1.55;
    margin-bottom: 20px;
}

.rpi-warning {
    background: #fffbeb;
    border-left: 4px solid #f59e0b;
    border-radius: 0 8px 8px 0;
    padding: 14px 18px;
    font-size: 0.85rem;
    color: #92400e;
    line-height: 1.55;
    margin-bottom: 20px;
}

/* ==========================================================================
   Use Case Cards (Tab 6 — Camera Use)
   ========================================================================== */
.rpi-usecase-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 20px 24px;
    margin-bottom: 16px;
}

.rpi-usecase-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 10px;
}

.rpi-usecase-card ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.rpi-usecase-card li {
    padding: 4px 0;
    font-size: 0.84rem;
    color: #475569;
    border-bottom: 1px solid #f1f5f9;
    line-height: 1.55;
}

.rpi-usecase-card li:last-child {
    border-bottom: none;
}

.rpi-usecase-card li strong {
    color: #1e293b;
}

/* ==========================================================================
   Essential Config Cards (3-col grid)
   ========================================================================== */
.rpi-config-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.rpi-config-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 20px;
}

.rpi-config-card h4 {
    font-size: 0.9rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 8px 0;
}

.rpi-config-card p {
    font-size: 0.82rem;
    color: #475569;
    line-height: 1.55;
    margin: 0;
}

@media (max-width: 900px) {
    .rpi-config-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Fleet Links Grid (2-col)
   ========================================================================== */
.rpi-links-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.rpi-link-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 14px 16px;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.rpi-link-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #3b82f6;
    text-decoration: none;
    color: inherit;
}

.rpi-link-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #eff6ff;
    color: #3b82f6;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rpi-link-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1e293b;
}

.rpi-link-desc {
    font-size: 0.78rem;
    color: #64748b;
}

@media (max-width: 600px) {
    .rpi-links-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 1024px) {
    .rpi-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .rpi-main {
        padding: 24px 16px 40px;
    }

    .rpi-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 580px) {
    .rpi-main {
        padding: 20px 12px 32px;
    }

    .rpi-stats {
        grid-template-columns: 1fr;
    }

    .rpi-tab {
        padding: 8px 14px;
        font-size: 0.8rem;
    }

    .rpi-section-title {
        font-size: 1rem;
    }

    .rpi-table {
        font-size: 0.8rem;
    }

    .rpi-table th,
    .rpi-table td {
        padding: 8px 10px;
    }

    .rpi-card {
        padding: 16px;
    }
}

/* ==========================================================================
   Dark Mode Overrides
   ========================================================================== */

/* --- Tabs --- */
[data-theme="dark"] .rpi-tabs {
    border-bottom-color: #334155;
}

[data-theme="dark"] .rpi-tab {
    color: #94a3b8;
}

[data-theme="dark"] .rpi-tab:hover {
    color: #e2e8f0;
}

[data-theme="dark"] .rpi-tab.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
}

/* --- Stats --- */
[data-theme="dark"] .rpi-stat {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .rpi-stat-value {
    color: #e2e8f0;
}

[data-theme="dark"] .rpi-stat-label {
    color: #94a3b8;
}

[data-theme="dark"] .rpi-stat-sub {
    color: #64748b;
}

/* --- Section titles --- */
[data-theme="dark"] .rpi-section-title {
    color: #e2e8f0;
    border-color: #334155;
}

/* --- Tables --- */
[data-theme="dark"] .rpi-table-wrap {
    border-color: #334155;
}

[data-theme="dark"] .rpi-table th {
    background: #1e293b;
    color: #e2e8f0;
    border-bottom-color: #334155;
}

[data-theme="dark"] .rpi-table td {
    color: #94a3b8;
    border-bottom-color: #334155;
}

[data-theme="dark"] .rpi-table td strong {
    color: #e2e8f0;
}

[data-theme="dark"] .rpi-table tbody tr:nth-child(even) {
    background: rgba(51, 65, 85, 0.3);
}

[data-theme="dark"] .rpi-table tbody tr:hover {
    background: rgba(51, 65, 85, 0.5);
}

[data-theme="dark"] .rpi-table code,
[data-theme="dark"] .rpi-config-card code {
    background: #334155;
    color: #e2e8f0;
}

/* --- Info cards --- */
[data-theme="dark"] .rpi-card {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .rpi-card-title {
    color: #e2e8f0;
}

[data-theme="dark"] .rpi-card-desc {
    color: #94a3b8;
}

/* --- Badges --- */
[data-theme="dark"] .rpi-badge-green {
    background-color: rgba(34, 197, 94, 0.18);
    color: #86efac;
}

[data-theme="dark"] .rpi-badge-amber {
    background-color: rgba(245, 158, 11, 0.18);
    color: #fcd34d;
}

[data-theme="dark"] .rpi-badge-red {
    background-color: rgba(239, 68, 68, 0.18);
    color: #fca5a5;
}

[data-theme="dark"] .rpi-badge-blue {
    background-color: rgba(59, 130, 246, 0.18);
    color: #93c5fd;
}

[data-theme="dark"] .rpi-badge-slate {
    background-color: #334155;
    color: #cbd5e1;
}

/* --- Note / Warning callouts --- */
[data-theme="dark"] .rpi-note {
    background: rgba(59, 130, 246, 0.1);
    border-left-color: #3b82f6;
    color: #93c5fd;
}

[data-theme="dark"] .rpi-warning {
    background: rgba(245, 158, 11, 0.1);
    border-left-color: #f59e0b;
    color: #fcd34d;
}

/* --- Use Case Cards --- */
[data-theme="dark"] .rpi-usecase-card {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .rpi-usecase-title {
    color: #e2e8f0;
}

[data-theme="dark"] .rpi-usecase-card li {
    color: #94a3b8;
    border-color: #334155;
}

[data-theme="dark"] .rpi-usecase-card li strong {
    color: #e2e8f0;
}

/* --- Config Cards --- */
[data-theme="dark"] .rpi-config-card {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .rpi-config-card h4 {
    color: #e2e8f0;
}

[data-theme="dark"] .rpi-config-card p {
    color: #94a3b8;
}

/* --- Fleet Link Cards --- */
[data-theme="dark"] .rpi-link-card {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .rpi-link-card:hover {
    border-color: #3b82f6;
}

[data-theme="dark"] .rpi-link-icon {
    background: rgba(59, 130, 246, 0.15);
}

[data-theme="dark"] .rpi-link-title {
    color: #e2e8f0;
}

[data-theme="dark"] .rpi-link-desc {
    color: #94a3b8;
}
