/* ============================================================
   LabelMe Vehicle — Anotador de Avarias
   Custom styles (Bootstrap 5 loaded for base layout only)
   Tema: Azul bebê pastel harmonioso
   ============================================================ */

/* ---------- Reset & base ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #e8f4f8;
    color: #1a3a4a;
}

/* ---------- Toolbar (top bar) ---------- */
.toolbar {
    height: 52px;
    background: #d0e8f0;
    border-bottom: 1px solid #b8dce6;
    flex-shrink: 0;
}

.toolbar .separator {
    margin: 0 4px;
    user-select: none;
}

.tool-btn.active {
    background-color: #7dd3fc !important;
    border-color: #7dd3fc !important;
    color: #1a3a4a !important;
}

/* ---------- Main content layout ---------- */
.main-content {
    display: flex;
    height: calc(100vh - 52px);
}

/* ---------- Sidebar (left panel) ---------- */
.sidebar {
    width: 300px;
    min-width: 300px;
    background: #e8f4f8;
    border-right: 1px solid #b8dce6;
    overflow-y: auto;
    padding: 12px;
}

/* Sidebar sections */
.sidebar-section {
    min-height: 60px;
    margin-bottom: 8px;
}

#photos-list {
    min-height: 80px;
}

.sidebar-header h6 {
    color: #5a7a8a;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    font-weight: 600;
}

/* Search section */
.search-section .input-group {
    background: #e8f4f8;
    border-radius: 6px;
    overflow: hidden;
}

.search-section .form-control {
    background: #d0e8f0;
    border: 1px solid #b8dce6;
    color: #1a3a4a;
    font-size: 0.8rem;
}

.search-section .form-control:focus {
    border-color: #7dd3fc;
    box-shadow: 0 0 0 2px #7dd3fc33;
}

.search-section .btn-primary {
    background: #7dd3fc;
    border: none;
    color: #1a3a4a;
    font-size: 0.8rem;
    white-space: nowrap;
}

.search-section .btn-primary:hover {
    background: #5bb8e6;
}

/* Inspection list items */
.inspection-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s;
    margin-bottom: 4px;
}

.inspection-item:hover {
    background-color: #d0e8f0;
}

.inspection-item.active {
    background-color: #b8dce6;
    border-left: 3px solid #7dd3fc;
}

.inspection-item .inspection-id {
    font-size: 0.8rem;
    color: #1a3a4a;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.inspection-item .status-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
}

.status-pending      { background: #fef3c7cc; color: #92400e; }
.status-in_progress  { background: #7dd3fccc; color: #1a5a8a; }
.status-completed    { background: #bbf7d0cc; color: #166534; }
.status-external     { background: #bae6fdcc; color: #0369a1; }

/* ---------- Inspection cards (accordion) ---------- */
.inspection-card {
    border: 1px solid #b8dce6;
    border-radius: 8px;
    margin-bottom: 8px;
    overflow: hidden;
    transition: border-color 0.2s ease;
}

.inspection-card:hover {
    border-color: #7dd3fc;
}

.inspection-card.expanded {
    border-color: #7dd3fc;
}

/* Card header (clickable toggle) */
.inspection-card-header {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    cursor: pointer;
    background: #d0e8f0;
    transition: background-color 0.15s;
    user-select: none;
}

.inspection-card-header:hover {
    background: #b8dce6;
}

.inspection-card.expanded .inspection-card-header {
    background: #b8dce6;
}

/* Chevron icon */
.chevron {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-left: 8px;
    color: #5a7a8a;
    transition: transform 0.2s ease;
}

.inspection-card.expanded .chevron {
    transform: rotate(180deg);
}

/* Card body (collapsible content) */
.inspection-card-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: #e8f4f8;
}

.inspection-card.expanded .inspection-card-body {
    max-height: 3000px;
}

/* Photos grid inside card */
.card-photos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    grid-auto-rows: auto;
    gap: 6px;
    padding: 10px;
}

.card-photos .photo-item {
    margin-bottom: 0;
}

/* Annotations list inside card */
.card-annotations {
    border-top: 1px solid #b8dce6;
    padding: 8px 10px;
}

.card-annotations .annotation-item {
    margin-bottom: 4px;
}

/* Photos section header (inside card) */
.card-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px 4px;
    color: #5a7a8a;
    text-transform: uppercase;
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    font-weight: 600;
}

/* ---------- Photos list items (fallback) ---------- */
.photo-item {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s;
    margin-bottom: 4px;
}

.photo-item:hover {
    background-color: #d0e8f0;
}

.photo-item.active {
    background-color: #b8dce6;
    border-left: 3px solid #7dd3fc;
}

.photo-thumb {
    width: 48px;
    height: 36px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 8px;
    background: #d0e8f0;
}

/* Placeholder for photos whose thumbnails can't load (external URLs) */
.photo-thumb-placeholder {
    display: inline-block;
    width: 48px;
    height: 36px;
    border-radius: 4px;
    margin-right: 8px;
    background: #d0e8f0;
    border: 1px solid #b8dce6;
}

.photo-label {
    font-size: 0.78rem;
    color: #1a3a4a;
}

/* Annotation list items */
.annotation-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s;
    margin-bottom: 4px;
    font-size: 0.82rem;
}

.annotation-item:hover {
    background-color: #d0e8f0;
}

.annotation-item.selected {
    background-color: #b8dce6;
    border-left: 3px solid #7dd3fc;
}

.annotation-item .annotation-class {
    font-weight: 600;
    margin-right: 6px;
}

.annotation-item .annotation-level {
    font-size: 0.7rem;
    padding: 1px 5px;
    border-radius: 3px;
    margin-right: 4px;
}

.annotation-item .annotation-view {
    font-size: 0.7rem;
    padding: 1px 5px;
    border-radius: 3px;
    margin-right: 4px;
    background: #fef3c7cc;
    color: #92400e;
}

.annotation-item .annotation-part {
    font-size: 0.72rem;
    color: #5a7a8a;
}

.annotation-item .annotation-obs {
    display: block;
    font-size: 0.7rem;
    color: #6a9aaa;
    margin-top: 2px;
    font-style: italic;
}

/* Annotation delete button */
.annotation-delete {
    padding: 2px 4px;
    margin-left: auto;
    opacity: 0;
    transition: opacity 0.15s;
    background: transparent;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
}

.annotation-item:hover .annotation-delete {
    opacity: 1;
}

.annotation-delete:hover svg {
    stroke: #ef4444 !important;
}

/* ---------- Canvas area ---------- */
.canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #f0f8fc;
}

#annotation-canvas {
    display: block;
    cursor: crosshair;
}

/* Loading overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(232, 244, 248, 0.85);
    z-index: 100;
    pointer-events: none; /* Never block mouse events, even when visible */
}

/* ---------- Modal overlay ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(26, 58, 74, 0.35);
    z-index: 1000;
}

.modal-dialog {
    background: #f0f8fc;
    border: 1px solid #b8dce6;
    border-radius: 10px;
    min-width: 400px;
    max-width: 500px;
}

.modal-content {
    background: transparent;
    border: none;
    border-radius: 10px;
}

.modal-header {
    border-bottom: 1px solid #b8dce6;
    padding: 16px 20px;
}

.modal-title {
    color: #1a3a4a;
    font-size: 1.1rem;
}

.modal-body {
    padding: 20px;
}

.modal-body label {
    color: #5a7a8a;
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.modal-body .form-select,
.modal-body .form-control {
    background: #e8f4f8;
    border: 1px solid #b8dce6;
    color: #1a3a4a;
    border-radius: 6px;
}

.modal-body .form-select:focus,
.modal-body .form-control:focus {
    border-color: #7dd3fc;
    box-shadow: 0 0 0 2px #7dd3fc33;
}

.modal-footer {
    border-top: 1px solid #b8dce6;
    padding: 12px 20px;
}

.modal-footer .btn {
    border-radius: 6px;
    font-size: 0.85rem;
}

/* ---------- Scrollbar styling ---------- */
.sidebar::-webkit-scrollbar,
#annotations-list::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track,
#annotations-list::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb,
#annotations-list::-webkit-scrollbar-thumb {
    background: #b8dce6;
    border-radius: 3px;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .sidebar {
        width: 240px;
        min-width: 240px;
    }
}

@media (max-width: 576px) {
    .main-content {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        min-width: unset;
        height: 200px;
        border-right: none;
        border-bottom: 1px solid #b8dce6;
    }
}

/* ========== Config CRUD Modal ========== */

.config-crud-tabs .nav-link {
    color: #5a7a8a;
    font-size: 0.75rem;
    padding: 4px 14px;
    border-radius: 6px;
    border: 1px solid transparent;
    transition: all 0.15s;
}

.config-crud-tabs .nav-link:hover {
    color: #1a3a4a;
    background-color: #d0e8f0;
}

.config-crud-tabs .nav-link.active {
    color: #7dd3fc;
    background-color: #e8f4f8;
    border-color: #7dd3fc44;
}

.config-crud-table th {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #5a7a8a;
    border-bottom: 1px solid #b8dce6;
    background-color: #e8f4f8;
    padding: 6px 10px;
}

.config-crud-table td {
    vertical-align: middle;
    padding: 4px 8px;
    border-bottom: 1px solid #d0e8f022;
    font-size: 0.8rem;
}

.config-crud-table tbody tr:hover {
    background-color: #d0e8f044;
}

.config-crud-table .crud-input {
    background-color: #e8f4f8;
    color: #1a3a4a;
    border-color: #b8dce6;
    font-size: 0.8rem;
}

.config-crud-table .crud-input:focus {
    background-color: #e8f4f8;
    color: #1a3a4a;
    border-color: #7dd3fc;
    box-shadow: 0 0 0 0.15rem #7dd3fc33;
}

.config-crud-table .crud-color-input {
    width: 36px;
    height: 28px;
    padding: 2px;
    border-radius: 4px;
}

.config-crud-table .form-select {
    background-color: #e8f4f8;
    color: #1a3a4a;
    border-color: #b8dce6;
    font-size: 0.8rem;
}

.config-crud-table .form-select:focus {
    border-color: #7dd3fc;
    box-shadow: 0 0 0 0.15rem #7dd3fc33;
}

#config-crud-add-btn {
    font-size: 0.75rem;
    border-radius: 6px;
}

#config-crud-add-btn:hover {
    background-color: #86efac !important;
    color: #1a3a4a !important;
}

/* ========== Config CRUD Section ========== */

.config-tabs .nav-link {
    color: #5a7a8a;
    font-size: 0.75rem;
    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid transparent;
    transition: all 0.15s;
}

.config-tabs .nav-link:hover {
    color: #1a3a4a;
    background-color: #d0e8f0;
}

.config-tabs .nav-link.active {
    color: #7dd3fc;
    background-color: #e8f4f8;
    border-color: #7dd3fc44;
}

#crud-table-container {
    max-height: 240px;
    overflow-y: auto;
    border: 1px solid #b8dce6;
    border-radius: 6px;
    background-color: #f0f8fc;
}

#crud-table-container::-webkit-scrollbar {
    width: 6px;
}

#crud-table-container::-webkit-scrollbar-track {
    background: #e8f4f8;
}

#crud-table-container::-webkit-scrollbar-thumb {
    background: #b8dce6;
    border-radius: 3px;
}

.config-table th {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #5a7a8a;
    border-bottom: 1px solid #b8dce6;
    background-color: #e8f4f8;
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 6px 10px;
}

.config-table td {
    vertical-align: middle;
    padding: 4px 8px;
    border-bottom: 1px solid #d0e8f022;
    font-size: 0.8rem;
}

.config-table tbody tr:hover {
    background-color: #d0e8f044;
}

.config-table .crud-input {
    background-color: #e8f4f8;
    color: #1a3a4a;
    border-color: #b8dce6;
    font-size: 0.8rem;
}

.config-table .crud-input:focus {
    background-color: #e8f4f8;
    color: #1a3a4a;
    border-color: #7dd3fc;
    box-shadow: 0 0 0 0.15rem #7dd3fc33;
}

.config-table .crud-color-input {
    width: 36px;
    height: 28px;
    padding: 2px;
    border-radius: 4px;
}

.config-table .form-select {
    background-color: #e8f4f8;
    color: #1a3a4a;
    border-color: #b8dce6;
    font-size: 0.8rem;
}

.config-table .form-select:focus {
    border-color: #7dd3fc;
    box-shadow: 0 0 0 0.15rem #7dd3fc33;
}

#crud-add-btn-damage-classes {
    font-size: 0.75rem;
    border-radius: 6px;
}

#crud-add-btn-damage-classes:hover {
    background-color: #86efac !important;
    color: #1a3a4a !important;
}
