/* PCCU Repair System - Custom Styles */

/* 照片服務異常時，網址 helper 只輸出 data:,，避免瀏覽器連線照片 API。 */
body[data-photo-storage-available="false"] [data-photo-upload],
body[data-photo-storage-available="false"] img[src="data:,"],
body[data-photo-storage-available="false"] a[href="data:,"],
body[data-photo-storage-available="false"] button:has(img[src="data:,"]),
body[data-photo-storage-available="false"] figure:has(img[src="data:,"]) {
    display: none !important;
}

/* Base styles */
html {
    --app-control-min-height: 2.5rem;
    --app-control-padding-y: 0.625rem;
    --app-table-padding-y: 1rem;
    font-size: 14px;
    scroll-behavior: smooth;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

html.font-large {
    --app-control-min-height: 2.875rem;
    --app-control-padding-y: 0.75rem;
    --app-table-padding-y: 1.125rem;
    font-size: 16px;
}

html.font-xlarge {
    --app-control-min-height: 3.125rem;
    --app-control-padding-y: 0.875rem;
    --app-table-padding-y: 1.25rem;
    font-size: 18px;
}

html.font-xxlarge {
    --app-control-min-height: 3.375rem;
    --app-control-padding-y: 1rem;
    --app-table-padding-y: 1.375rem;
    font-size: 20px;
}

@media (min-width: 768px) {
    html.font-large {
        font-size: 18px;
    }

    html.font-xlarge {
        font-size: 20px;
    }

    html.font-xxlarge {
        font-size: 22px;
    }
}

/* Focus states for accessibility */
.focus-ring:focus,
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid #107dd5;
    outline-offset: 2px;
}

/* Custom form styles */
.form-input,
.form-select,
.form-textarea {
    width: 100%;
    min-height: var(--app-control-min-height);
    border-radius: 0.5rem;
    border: 1px solid #dbe1e6;
    background-color: white;
    padding: var(--app-control-padding-y) 1rem;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: #107dd5;
    box-shadow: 0 0 0 3px rgba(16, 125, 213, 0.1);
    outline: none;
}

.dark .form-input,
.dark .form-select,
.dark .form-textarea {
    background-color: #1A2632;
    border-color: #2d3b4a;
    color: white;
}

/* Button styles */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: var(--app-control-min-height);
    padding: var(--app-control-padding-y) 1.5rem;
    border-radius: 0.5rem;
    background-color: #107dd5;
    color: white;
    font-weight: 700;
    font-size: 1rem;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px 0 rgba(16, 125, 213, 0.3);
}

.btn-primary:hover {
    background-color: #0a5fa3;
    transform: scale(1.02);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: var(--app-control-min-height);
    padding: var(--app-control-padding-y) 1.5rem;
    border-radius: 0.5rem;
    background-color: rgba(16, 125, 213, 0.1);
    color: #107dd5;
    font-weight: 700;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background-color: rgba(16, 125, 213, 0.2);
}

.btn-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: var(--app-control-min-height);
    padding: var(--app-control-padding-y) 1.5rem;
    border-radius: 0.5rem;
    border: 1px solid #dbe1e6;
    background-color: transparent;
    color: #111518;
    font-weight: 700;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.btn-outline:hover {
    background-color: #f6f7f8;
    border-color: #107dd5;
    color: #107dd5;
}

.dark .btn-outline {
    border-color: #2d3b4a;
    color: white;
}

.dark .btn-outline:hover {
    background-color: #1A2632;
}

/* Card styles */
.card {
    background-color: white;
    border-radius: 0.75rem;
    border: 1px solid #dbe1e6;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
}

.dark .card {
    background-color: #1A2632;
    border-color: #2d3b4a;
}

/* Table styles */
.table-container {
    overflow-x: auto;
    border-radius: 0.75rem;
    border: 1px solid #dbe1e6;
    background-color: white;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.dark .table-container {
    background-color: #1A2632;
    border-color: #2d3b4a;
}

.data-table {
    width: 100%;
    text-align: left;
    font-size: 1rem;
}

.data-table thead {
    background-color: #f8fafc;
    border-bottom: 1px solid #dbe1e6;
}

.dark .data-table thead {
    background-color: #1e2936;
    border-color: #2d3b4a;
}

.data-table th {
    padding: var(--app-table-padding-y) 1.5rem;
    font-weight: 600;
    color: #111518;
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 0.05em;
}

.dark .data-table th {
    color: #94a3b8;
}

.data-table td {
    padding: var(--app-table-padding-y) 1.5rem;
    border-bottom: 1px solid #f1f5f9;
}

.dark .data-table td {
    border-color: #2d3b4a;
}

.data-table tbody tr:hover {
    background-color: #f8fafc;
}

.dark .data-table tbody tr:hover {
    background-color: rgba(30, 41, 54, 0.5);
}

/* Status badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
}

.preference-switcher {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
    max-width: 100%;
    color: #475569;
    font-size: 0.875rem;
    font-weight: 500;
}

.preference-switcher .preference-select {
    appearance: auto;
    min-height: 2.75rem;
    max-width: 100%;
    padding: 0.375rem 0.625rem;
    border: 1px solid #dbe1e6;
    border-radius: 0.5rem;
    background-color: #fff;
    background-image: none;
    color: #334155;
    font: inherit;
    cursor: pointer;
    color-scheme: light;
}

.preference-switcher .preference-select:hover {
    border-color: #64748b;
}

.preference-switcher .preference-select:focus-visible {
    outline: 2px solid #107dd5;
    outline-offset: 2px;
}

.dark .preference-switcher {
    color: #cbd5e1;
}

.dark .preference-switcher .preference-select {
    border-color: #64748b;
    background-color: #1e293b;
    color: #f1f5f9;
    color-scheme: dark;
}

.dark .preference-switcher .preference-select:hover {
    border-color: #94a3b8;
}

.badge-primary {
    background-color: rgba(16, 125, 213, 0.1);
    color: #107dd5;
}

.badge-success {
    background-color: rgba(34, 197, 94, 0.1);
    color: #16a34a;
}

.badge-warning {
    background-color: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.badge-danger {
    background-color: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.badge-secondary {
    background-color: #f1f5f9;
    color: #64748b;
}

/* Loading spinner */
.spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid #e2e8f0;
    border-top-color: #107dd5;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* AI Loading indicator (inline, e.g. RepairForm action bar) */
.ai-loading { display: none; }
.ai-loading.active { display: flex; align-items: center; }

/* AI Loading overlay */
.ai-loading-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.ai-loading-card {
    background-color: white;
    border-radius: 1rem;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.dark .ai-loading-card {
    background-color: #1A2632;
}

/* Animations */
@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Shared management-page switch */
.status-switch {
    --status-switch-active: #107dd5;
    --status-switch-active-text: #0d6ab6;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border-radius: 9999px;
    cursor: pointer;
    user-select: none;
}

.status-switch--primary {
    --status-switch-active: #107dd5;
    --status-switch-active-text: #0d6ab6;
}

.status-switch--emerald {
    --status-switch-active: #10b981;
    --status-switch-active-text: #047857;
}

.status-switch--sky {
    --status-switch-active: #0ea5e9;
    --status-switch-active-text: #0369a1;
}

.status-switch--amber {
    --status-switch-active: #f59e0b;
    --status-switch-active-text: #b45309;
}

.status-switch__input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.status-switch__track {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
    width: 2.75rem;
    height: 1.5rem;
    border-radius: 9999px;
    background-color: #e2e8f0;
    transition: background-color 180ms ease, box-shadow 180ms ease;
}

.status-switch__track::after {
    position: absolute;
    top: 0.125rem;
    left: 0.125rem;
    width: 1.25rem;
    height: 1.25rem;
    content: "";
    border-radius: 9999px;
    background-color: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.28);
    transition: transform 180ms ease;
}

.status-switch:hover .status-switch__track {
    filter: brightness(0.97);
}

.status-switch__input:checked + .status-switch__track {
    background-color: var(--status-switch-active);
}

.status-switch__input:checked + .status-switch__track::after {
    transform: translateX(1.25rem);
}

.status-switch__input:focus-visible + .status-switch__track {
    outline: 2px solid var(--status-switch-active);
    outline-offset: 2px;
}

.status-switch__text {
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1rem;
}

.status-switch__text-on {
    display: none;
}

.status-switch__input:checked ~ .status-switch__text {
    color: var(--status-switch-active-text);
}

.status-switch__input:checked ~ .status-switch__text .status-switch__text-on {
    display: inline;
}

.status-switch__input:checked ~ .status-switch__text .status-switch__text-off {
    display: none;
}

.status-switch__input:disabled ~ .status-switch__track,
.status-switch__input:disabled ~ .status-switch__text {
    opacity: 0.6;
}

.status-switch:has(.status-switch__input:disabled) {
    cursor: default;
}

.dark .status-switch__track {
    background-color: #475569;
}

.dark .status-switch__text {
    color: #cbd5e1;
}

.dark .status-switch--primary {
    --status-switch-active-text: #7dd3fc;
}

.dark .status-switch--emerald {
    --status-switch-active-text: #6ee7b7;
}

.dark .status-switch--sky {
    --status-switch-active-text: #7dd3fc;
}

.dark .status-switch--amber {
    --status-switch-active-text: #fcd34d;
}

@media (prefers-reduced-motion: reduce) {
    .status-switch__track,
    .status-switch__track::after {
        transition: none;
    }
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }

    body {
        background-color: white !important;
        color: black !important;
    }

    .card {
        border: 1px solid #000 !important;
        box-shadow: none !important;
    }
}

/* Use a plain-language prompt instead of the browser's technical date mask. */
.schedule-date-placeholder {
    position: absolute;
    inset-inline-start: 1rem;
    top: 50%;
    color: #64748b;
    pointer-events: none;
    transform: translateY(-50%);
}

.dark .schedule-date-placeholder {
    color: #9ca3af;
}

.schedule-date-shell:not(.is-empty) .schedule-date-placeholder {
    display: none;
}

.schedule-date-shell.is-empty .schedule-date,
.schedule-date-shell.is-empty .schedule-date::-webkit-datetime-edit,
.schedule-date-shell.is-empty .schedule-date::-webkit-datetime-edit-fields-wrapper,
.schedule-date-shell.is-empty .schedule-date::-webkit-datetime-edit-text,
.schedule-date-shell.is-empty .schedule-date::-webkit-datetime-edit-month-field,
.schedule-date-shell.is-empty .schedule-date::-webkit-datetime-edit-day-field,
.schedule-date-shell.is-empty .schedule-date::-webkit-datetime-edit-year-field {
    color: transparent;
}

.schedule-date-shell.is-empty .schedule-date::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 1;
}

/* Vendor work list: reserve space for the trade and full location. */
.vendor-assignment-table { width: 100%; table-layout: fixed; }
.vendor-assignment-table th:nth-child(1) { width: 23%; }
.vendor-assignment-table th:nth-child(2) { width: 32%; }
.vendor-assignment-table th:nth-child(3) { width: 19%; }
.vendor-assignment-table th:nth-child(4) { width: 16%; }
.vendor-assignment-table th:nth-child(5) { width: 10%; }
.vendor-assignment-table th,
.vendor-assignment-table td {
    padding-inline: 1rem;
    overflow-wrap: anywhere;
    white-space: normal;
}
.vendor-assignment-mobile-label { display: none; }

@media (max-width: 767px) {
    .vendor-assignment-table,
    .vendor-assignment-table thead,
    .vendor-assignment-table tbody { display: block; }
    .vendor-assignment-table tr {
        display: grid;
        grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
        padding: 0.75rem;
        column-gap: 1rem;
        row-gap: 0.75rem;
    }
    .vendor-assignment-table th,
    .vendor-assignment-table td {
        width: auto;
        min-width: 0;
        padding: 0;
        text-align: left;
    }
    .vendor-assignment-table th:nth-child(n) { width: auto; }
    .vendor-assignment-table th:nth-child(n+3) { display: none; }
    .vendor-assignment-case { font-size: 0.875rem; }
    .vendor-assignment-location { line-height: 1.6; }
    .vendor-assignment-action { grid-column: 1 / -1; }
    .vendor-assignment-action a { min-height: 2.75rem; }
    .vendor-assignment-mobile-label { display: inline; }
}
