/* TaskOS — App Styles */
/* Dark theme only. Font: Inter. */

/* Inter Font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

html {
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #0F172A; /* slate-900 */
    color: #F1F5F9; /* slate-100 */
    min-height: 100vh;
}

/* ========== TYPOGRAPHY ========== */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    line-height: 1.25;
    color: #FFFFFF;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }

p { color: #CBD5E1; /* slate-300 */ }

a {
    color: #3B82F6; /* blue-500 */
    text-decoration: none;
    transition: color 0.2s;
}
a:hover { color: #60A5FA; /* blue-400 */ }

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #0F172A; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #475569; }

/* ========== FOCUS STYLES ========== */
*:focus-visible {
    outline: 2px solid #3B82F6;
    outline-offset: 2px;
}

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 40px;
    text-decoration: none;
}

.btn-primary {
    background-color: #3B82F6;
    color: #FFFFFF;
}
.btn-primary:hover { background-color: #2563EB; color: #FFFFFF; }

.btn-secondary {
    background-color: #1E293B;
    color: #F1F5F9;
    border: 1px solid #334155;
}
.btn-secondary:hover { background-color: #334155; color: #FFFFFF; }

.btn-outline {
    background-color: transparent;
    color: #3B82F6;
    border: 1px solid #3B82F6;
}
.btn-outline:hover { background-color: #3B82F6; color: #FFFFFF; }

.btn-lg {
    padding: 0.75rem 1.75rem;
    font-size: 1rem;
    min-height: 48px;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    min-height: 32px;
}

/* ========== FORM INPUTS ========== */
.form-input {
    display: block;
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    color: #F1F5F9;
    background-color: #0F172A;
    border: 1px solid #334155;
    border-radius: 0.5rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-height: 42px;
}
.form-input::placeholder { color: #64748B; }
.form-input:focus {
    outline: none;
    border-color: #3B82F6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.form-input.is-invalid { border-color: #EF4444; }

.form-label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #CBD5E1;
}

/* ========== CARDS ========== */
.card {
    background-color: #1E293B; /* slate-800 */
    border-radius: 0.75rem;
    border: 1px solid #334155; /* slate-700 */
    padding: 1.5rem;
}

/* ========== TOAST ========== */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 400px;
}

.toast {
    padding: 0.875rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: #FFFFFF;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: toast-in 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.toast-success { background-color: #166534; border: 1px solid #22C55E; }
.toast-error { background-color: #7F1D1D; border: 1px solid #EF4444; }
.toast-warning { background-color: #78350F; border: 1px solid #F59E0B; }
.toast-info { background-color: #1E3A5F; border: 1px solid #3B82F6; }

.toast-close {
    margin-left: auto;
    background: none;
    border: none;
    color: #94A3B8;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

/* ========== BADGE ========== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
}
.badge-blue { background-color: rgba(59, 130, 246, 0.2); color: #60A5FA; }
.badge-green { background-color: rgba(34, 197, 94, 0.2); color: #4ADE80; }
.badge-red { background-color: rgba(239, 68, 68, 0.2); color: #F87171; }
.badge-yellow { background-color: rgba(245, 158, 11, 0.2); color: #FBBF24; }

/* ========== ACCORDION ========== */
.accordion-item {
    border-bottom: 1px solid #334155;
}

.accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 1rem 0;
    background: none;
    border: none;
    color: #F1F5F9;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: color 0.2s;
}
.accordion-header:hover { color: #3B82F6; }

.accordion-icon {
    transition: transform 0.3s;
    color: #64748B;
}
.accordion-icon.open { transform: rotate(180deg); }

.accordion-body {
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    max-height: 0;
    padding: 0;
}
.accordion-body.open {
    max-height: 500px;
    padding: 0 0 1rem 0;
}

.accordion-body p {
    color: #94A3B8;
    line-height: 1.6;
}

/* ========== SIDEBAR ========== */
.sidebar {
    width: 260px;
    min-height: 100vh;
    background-color: #1E293B;
    border-right: 1px solid #334155;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    color: #94A3B8;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    cursor: pointer;
}
.sidebar-nav-item:hover {
    background-color: rgba(59, 130, 246, 0.1);
    color: #F1F5F9;
}
.sidebar-nav-item.active {
    background-color: rgba(59, 130, 246, 0.15);
    color: #3B82F6;
    border-left-color: #3B82F6;
}
.sidebar-nav-item i { width: 20px; text-align: center; }

/* ========== LOADING ========== */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #334155;
    border-top-color: #3B82F6;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 50;
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 40;
    }

    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
}

/* ========== METRIC CARDS ========== */
.metric-card {
    background-color: #1E293B;
    border: 1px solid #334155;
    border-radius: 0.75rem;
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.metric-card:hover {
    border-color: #475569;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.metric-card.metric-alert {
    border-color: #EF4444;
    animation: pulse-border 2s infinite;
}
@keyframes pulse-border {
    0%, 100% { border-color: #EF4444; }
    50% { border-color: rgba(239, 68, 68, 0.4); }
}

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ========== DATA TABLE ========== */
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748B;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #334155;
    background-color: #1E293B;
}
.data-table td {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: #F1F5F9;
    border-bottom: 1px solid #1E293B;
}
.data-table tr:hover td {
    background-color: rgba(59, 130, 246, 0.05);
}
.data-table tr.clickable {
    cursor: pointer;
}
.data-table tr.clickable:hover td {
    background-color: rgba(59, 130, 246, 0.1);
}

/* ========== DIALOG / MODAL ========== */
.dialog-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.dialog {
    background-color: #1E293B;
    border: 1px solid #334155;
    border-radius: 0.75rem;
    padding: 1.5rem;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.dialog-lg {
    max-width: 700px;
}
.dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}
.dialog-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: white;
}
.dialog-close {
    background: none;
    border: none;
    color: #64748B;
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0.25rem;
}
.dialog-close:hover { color: #94A3B8; }
.dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid #334155;
}

/* ========== PROGRESS BAR ========== */
.progress-bar {
    width: 100%;
    height: 8px;
    background-color: #334155;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
}
.progress-bar-segment {
    height: 100%;
    transition: width 0.3s ease;
}

/* ========== PAGINATION ========== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 1rem;
}
.pagination button {
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #334155;
    background-color: #1E293B;
    color: #94A3B8;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-family: 'Inter', sans-serif;
    transition: all 0.15s;
}
.pagination button:hover:not(:disabled) {
    background-color: #334155;
    color: white;
}
.pagination button.active {
    background-color: #3B82F6;
    border-color: #3B82F6;
    color: white;
}
.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ========== TABS ========== */
.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #334155;
    margin-bottom: 1rem;
}
.tab-item {
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #64748B;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s;
}
.tab-item:hover { color: #94A3B8; }
.tab-item.active {
    color: #3B82F6;
    border-bottom-color: #3B82F6;
}

/* ========== LEAFLET DARK THEME ========== */
.leaflet-container {
    background-color: #0F172A;
    font-family: 'Inter', sans-serif;
}
.leaflet-control-zoom a {
    background-color: #1E293B !important;
    color: #F1F5F9 !important;
    border-color: #334155 !important;
}
.leaflet-control-zoom a:hover {
    background-color: #334155 !important;
}
.leaflet-control-attribution {
    background-color: rgba(15, 23, 42, 0.8) !important;
    color: #64748B !important;
    font-size: 0.625rem !important;
}
.leaflet-control-attribution a { color: #94A3B8 !important; }
.leaflet-popup-content-wrapper {
    background-color: #1E293B;
    color: #F1F5F9;
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
.leaflet-popup-tip { background-color: #1E293B; }

/* ========== DRAG & DROP ========== */
.dragging {
    opacity: 0.5;
    background-color: rgba(59, 130, 246, 0.1) !important;
}
.drag-over {
    border-top: 2px solid #3B82F6 !important;
}

/* ========== CHECKBOX ========== */
input[type="checkbox"] {
    accent-color: #3B82F6;
}

/* ========== SELECT DROPDOWN ========== */
select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748B' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}
select.form-input option {
    background-color: #1E293B;
    color: #F1F5F9;
}

/* ========== PHOTO GALLERY (proof viewer) ========== */
.photo-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.5rem;
}
.photo-gallery img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 0.5rem;
    border: 1px solid #334155;
    cursor: pointer;
    transition: opacity 0.2s;
}
.photo-gallery img:hover { opacity: 0.8; }

/* ========== DRIVER PWA STYLES ========== */

/* Status badges */
.badge-status-pending { background-color: rgba(245, 158, 11, 0.15); color: #FBBF24; }
.badge-status-started { background-color: rgba(59, 130, 246, 0.15); color: #60A5FA; }
.badge-status-arrived { background-color: rgba(139, 92, 246, 0.15); color: #A78BFA; }
.badge-status-completed { background-color: rgba(34, 197, 94, 0.15); color: #4ADE80; }
.badge-status-failed { background-color: rgba(239, 68, 68, 0.15); color: #F87171; }
.badge-status-skipped { background-color: rgba(245, 158, 11, 0.15); color: #FBBF24; }

/* Driver bottom nav safe area for iOS */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .driver-bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Task group slide-out animation */
.task-group-exit {
    animation: slideOut 0.3s ease forwards;
}

@keyframes slideOut {
    from { opacity: 1; transform: translateX(0); max-height: 200px; }
    to { opacity: 0; transform: translateX(100%); max-height: 0; padding: 0; margin: 0; }
}

/* Pull to refresh transition */
.pull-refresh-enter-active {
    transition: all 0.3s ease;
}

/* Touch target minimum size */
.driver-touch-target {
    min-height: 48px;
    min-width: 48px;
}

/* Slider track */
.slider-track {
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

/* Signature canvas */
.signature-canvas {
    touch-action: none;
    cursor: crosshair;
}

/* Rotate helper */
.rotate-180 {
    transform: rotate(180deg);
}

/* ========== FONTAWESOME PATH FIX ========== */
/* Override FontAwesome webfont paths to use local webfonts directory */
@font-face {
    font-family: 'Font Awesome 6 Free';
    font-style: normal;
    font-weight: 900;
    font-display: block;
    src: url('../webfonts/fa-solid-900.woff2') format('woff2');
}

@font-face {
    font-family: 'Font Awesome 6 Free';
    font-style: normal;
    font-weight: 400;
    font-display: block;
    src: url('../webfonts/fa-regular-400.woff2') format('woff2');
}

@font-face {
    font-family: 'Font Awesome 6 Brands';
    font-style: normal;
    font-weight: 400;
    font-display: block;
    src: url('../webfonts/fa-brands-400.woff2') format('woff2');
}

/* ========== PRIMEICONS PATH FIX ========== */
@font-face {
    font-family: 'primeicons';
    font-display: block;
    src: url('../libs/primevue/fonts/primeicons.woff2') format('woff2'),
         url('../libs/primevue/fonts/primeicons.woff') format('woff'),
         url('../libs/primevue/fonts/primeicons.ttf') format('truetype');
}
