/**
 * BouwRegie (by BTPro) - Master Theme & Component Design System
 */

:root {
    --primary-color: #0284c7;
    --primary-hover: #0369a1;
    --primary-light: rgba(2, 132, 199, 0.12);
    --secondary-color: #0f172a;
    --secondary-hover: #1e293b;
    --accent-color: #f59e0b;
    --accent-light: rgba(245, 158, 11, 0.15);

    --bg-main: #f8fafc;
    --bg-surface: #ffffff;
    --border-color: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #64748b;

    --sidebar-width: 260px;
    --sidebar-bg: #0f172a;
    --sidebar-text: #e2e8f0;
    --sidebar-border: rgba(255, 255, 255, 0.08);

    --topbar-height: 64px;
    --header-bg: #ffffff;
    --header-border: #e2e8f0;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);

    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}
a:hover {
    color: var(--primary-hover);
}

/* Utilities & Components */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}
.card:hover {
    box-shadow: var(--shadow-md);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}
.btn-primary {
    background: var(--primary-color);
    color: #ffffff;
}
.btn-primary:hover {
    background: var(--primary-hover);
    color: #ffffff;
}
.btn-secondary {
    background: var(--secondary-color);
    color: #ffffff;
}
.btn-secondary:hover {
    background: var(--secondary-hover);
    color: #ffffff;
}
.btn-outline {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-main);
}
.btn-outline:hover {
    background: var(--bg-main);
    border-color: #cbd5e1;
}

/* Badge System */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 9999px;
    text-transform: capitalize;
}
.badge-primary { background: var(--primary-light); color: var(--primary-color); }
.badge-warning { background: var(--accent-light); color: var(--accent-color); }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-info { background: #e0f2fe; color: #0369a1; }
.badge-danger { background: #fee2e2; color: #b91c1c; }

/* Table Styles */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
}
.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.875rem;
}
.table th {
    background: #f1f5f9;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}
.table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    vertical-align: middle;
}
.table tr:last-child td {
    border-bottom: none;
}
.table tr:hover td {
    background-color: #f8fafc;
}

/* Form Controls */
.form-group {
    margin-bottom: 16px;
}
.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
}
.form-control {
    width: 100%;
    padding: 9px 12px;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: #ffffff;
    color: var(--text-main);
    outline: none;
    transition: var(--transition);
}
.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Multi-Device & Mobile Touch Standards (Bouwplaats Phone, Keet-iPad, Office Desktop) */
.touch-btn {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

@media (max-width: 768px) {
    .hide-on-mobile {
        display: none !important;
    }
}
@media (min-width: 769px) {
    .hide-on-desktop {
        display: none !important;
    }
}

/* ==========================================================================
   Searchable Select / Combobox Component
   ========================================================================== */
.searchable-combobox-wrapper {
    position: relative;
    width: 100%;
}

.combobox-control {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    background: #ffffff;
    border: 1px solid var(--border-color, #cbd5e1);
    border-radius: var(--radius-sm, 6px);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.04));
    min-height: 44px; /* Touch target >= 44px */
}

.combobox-control:focus-within,
.combobox-control.is-open {
    border-color: var(--primary-color, #0284c7);
    box-shadow: 0 0 0 3px var(--primary-light, rgba(2, 132, 199, 0.15));
}

.combobox-icon-slot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-left: 12px;
    padding-right: 4px;
    font-size: 1.15rem;
    color: var(--text-muted, #64748b);
    user-select: none;
    pointer-events: none;
    flex-shrink: 0;
}

.combobox-input {
    flex: 1;
    min-width: 0;
    border: none !important;
    outline: none !important;
    background: transparent !important;
    padding: 10px 8px 10px 8px !important;
    font-size: 0.9rem !important;
    color: var(--text-main, #0f172a) !important;
    box-shadow: none !important;
    min-height: 42px;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.combobox-input::placeholder {
    color: #94a3b8;
    font-size: 0.88rem;
}

.combobox-actions {
    display: inline-flex;
    align-items: center;
    padding-right: 8px;
    gap: 4px;
    flex-shrink: 0;
}

.combobox-clear-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    color: #64748b;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}

.combobox-clear-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.combobox-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    border-radius: 4px;
    transition: transform 0.2s ease, color 0.15s;
    padding: 0;
}

.combobox-toggle-btn:hover {
    color: var(--primary-color, #0284c7);
}

.combobox-control.is-open .combobox-toggle-btn svg {
    transform: rotate(180deg);
}

/* Floating Dropdown */
.combobox-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid var(--border-color, #cbd5e1);
    border-radius: var(--radius-md, 10px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.06);
    z-index: 1050;
    max-height: 320px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 6px;
    display: none;
}

.combobox-dropdown.is-open {
    display: block;
    animation: comboboxFadeIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes comboboxFadeIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Dropdown Item */
.combobox-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 48px; /* Touch target >= 44px */
    padding: 8px 12px;
    border-radius: var(--radius-sm, 6px);
    cursor: pointer;
    transition: background-color 0.12s ease;
    user-select: none;
    text-decoration: none;
    color: var(--text-main, #0f172a);
}

.combobox-item:hover,
.combobox-item.is-highlighted {
    background-color: var(--primary-light, rgba(2, 132, 199, 0.08));
}

.combobox-item.is-selected {
    background-color: rgba(2, 132, 199, 0.12);
    font-weight: 600;
}

.combobox-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.combobox-item-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.combobox-item-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.combobox-item-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main, #0f172a);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.combobox-item-subtitle {
    font-size: 0.76rem;
    color: var(--text-muted, #64748b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.combobox-item-right {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.combobox-city-pill {
    font-size: 0.72rem;
    font-weight: 600;
    color: #475569;
    background: #f1f5f9;
    padding: 3px 8px;
    border-radius: 12px;
    white-space: nowrap;
}

.combobox-check-icon {
    color: var(--primary-color, #0284c7);
    font-weight: 800;
    font-size: 0.95rem;
    display: none;
}

.combobox-item.is-selected .combobox-check-icon {
    display: inline-block;
}

.combobox-highlight {
    background: #fef08a;
    color: #713f12;
    padding: 0 2px;
    border-radius: 2px;
    font-weight: 700;
}

.combobox-empty {
    padding: 16px 14px;
    text-align: center;
    color: var(--text-muted, #64748b);
    font-size: 0.85rem;
}

.combobox-empty-create {
    margin-top: 8px;
    display: inline-block;
    color: var(--primary-color, #0284c7);
    font-weight: 600;
    text-decoration: none;
    font-size: 0.82rem;
}

.combobox-empty-create:hover {
    text-decoration: underline;
}

