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

:root {
    --sidebar-width: 240px;
    --mn-dark: #003865;
    --mn-light: #009FDA;
    --bg: #009FDA;
    --surface: rgba(255,255,255,0.92);
    --border: rgba(0,56,101,0.15);
    --text: #003865;
    --text-secondary: #3d6d8a;
    --primary: #003865;
    --primary-hover: #002a4e;
    --accent: #009FDA;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,56,101,0.08), 0 1px 2px rgba(0,56,101,0.06);
    --shadow-lg: 0 4px 12px rgba(0,56,101,0.12);
}

html { font-size: 15px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background: var(--mn-light);
    color: var(--text);
    min-height: 100vh;
}

/* === Dashboard Layout === */
.dashboard {
    display: flex;
    min-height: 100vh;
}

/* === Sidebar === */
.sidebar {
    width: var(--sidebar-width);
    background: var(--mn-dark);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    background-image: url('/images/rebel-loon.svg');
    background-repeat: no-repeat;
    background-position: center center;
    background-size: 70%;
}

.sidebar::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,56,101,0.75);
    z-index: -1;
}

.sidebar-brand {
    padding: 24px 20px;
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--mn-light);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.15s, background 0.15s;
}

.sidebar-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
}

.sidebar-link.active {
    color: #fff;
    background: rgba(0,159,218,0.15);
    border-right: 3px solid var(--mn-light);
}

.sidebar-footer {
    padding: 16px 0;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-footer .sidebar-link.external {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.5);
}

.sidebar-footer .sidebar-link.external:hover {
    color: var(--accent);
}

.sidebar-footer .sidebar-link svg {
    opacity: 0.6;
    flex-shrink: 0;
}

/* === Main Content === */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    background: var(--bg);
    min-height: 100vh;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 4px;
}

.page-body {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    margin: 32px 40px;
    padding: 32px;
}

.content-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 32px;
}

/* === Cards === */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.card-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
}

.card-header h2 {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.card-body {
    padding: 24px;
}

/* === Search Form === */
.search-card {
    margin-bottom: 28px;
}

.search-card .card-body { padding: 0; }

.search-form {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    padding: 20px 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group:first-child {
    flex: 0 0 auto;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.form-group input[type="text"] {
    width: 10em;
    padding: 10px 14px;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text);
    background: #fff;
    transition: border-color 0.15s;
    height: 42px;
}

.form-group input[type="text"]:focus {
    outline: none;
    border-color: var(--mn-dark);
    box-shadow: 0 0 0 3px rgba(0, 56, 101, 0.15);
}

.form-group select {
    padding: 10px 14px;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    height: 42px;
}

.btn-primary {
    padding: 10px 28px;
    font-size: 0.9rem;
    font-weight: 600;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
    height: 42px;
}

.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

/* === Spinner === */
.spinner {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 16px 24px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.spinner-dot {
    width: 20px;
    height: 20px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* === Error === */
.error-card {
    border-color: #fecaca;
    background: #fef2f2;
}

.error-text {
    color: var(--danger);
    font-size: 0.9rem;
}

.error-card .card-body { padding: 16px 24px; }

/* === Results Grid === */
.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

/* === Vehicle Info === */
.vehicle-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text);
}

.vehicle-details {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 4px;
}

.vehicle-links {
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.btn-retry {
    padding: 4px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 6px;
}

.btn-retry:hover { background: var(--primary-hover); }

.vehicle-links a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.vehicle-links a:hover {
    text-decoration: underline;
}

/* === Status Card === */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.status-badge {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
    flex-shrink: 0;
}

.badge-confirmed { background: #fee2e2; color: #991b1b; }
.badge-suspected { background: #fef3c7; color: #92400e; }
.badge-cleared { background: #dcfce7; color: #166534; }
.badge-unknown, .badge-no-entry, .badge-error { background: #f1f5f9; color: #64748b; }
.badge-similar { background: #fff7ed; color: #9a3412; }

.status-text {
    font-size: 1.1rem;
    font-weight: 700;
}

/* === Chips === */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.chip-confirmed { background: #fee2e2; color: #991b1b; }
.chip-suspected { background: #fef3c7; color: #92400e; }
.chip-cleared { background: #dcfce7; color: #166534; }
.chip-unknown, .chip-muted { background: #f1f5f9; color: #64748b; }
.chip-rental { background: #ede9fe; color: #5b21b6; }
.chip-tag { background: #e0f2fe; color: #075985; }
.chip-similar { background: #fff7ed; color: #9a3412; }

/* === Detail Grid === */
.detail-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 20px;
    margin-top: 12px;
    font-size: 0.85rem;
}

.detail-grid dt {
    font-weight: 600;
    color: var(--text-secondary);
}

.detail-grid dd {
    color: var(--text);
}

/* === Status Card border accents === */
.status-card.status-confirmed { border-top: 3px solid #dc2626; }
.status-card.status-suspected { border-top: 3px solid #d97706; }
.status-card.status-cleared { border-top: 3px solid #16a34a; }
.status-card.status-similar { border-top: 3px solid #ea580c; }

/* === Similar Plates === */
.similar-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.similar-item {
    display: block;
    padding: 14px 16px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.similar-item:hover {
    border-color: #94a3b8;
    box-shadow: var(--shadow);
}

.similar-plate {
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 1px;
    margin-bottom: 4px;
    color: var(--text);
}

.similar-meta {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: 6px;
}

.similar-item .chips { margin-bottom: 0; }

/* === Tools Grid (Landing Page) === */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.tool-card {
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.15s, transform 0.15s;
    cursor: pointer;
}

.tool-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.tool-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: var(--mn-dark);
    color: var(--mn-light);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.tool-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.tool-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* === Responsive === */
@media (max-width: 768px) {
    .sidebar {
        position: static;
        width: 100%;
        flex-direction: row;
        align-items: center;
        background-image: none;
    }

    .sidebar::after {
        display: none;
    }

    .sidebar-brand {
        padding: 12px 16px;
        border-bottom: none;
    }

    .sidebar-nav {
        display: flex;
        flex: 1;
        padding: 0;
    }

    .sidebar-link {
        padding: 12px 14px;
        font-size: 0.85rem;
    }

    .sidebar-link.active {
        border-right: none;
        border-bottom: 3px solid var(--mn-light);
    }

    .sidebar-footer {
        display: none;
    }

    .dashboard {
        flex-direction: column;
    }

    .main-content {
        margin-left: 0;
    }

    .page-body {
        margin: 16px;
        padding: 20px 16px;
    }

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

    .search-form {
        flex-wrap: wrap;
    }

    .form-group input[type="text"] {
        width: 100%;
    }

    .form-group:first-child {
        flex: 1 1 100%;
    }

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