:root {
    --vh: 1vh;

    /* safe-area fallback using env() */
    --safe-area-inset-top: env(safe-area-inset-top, 20px);
    --safe-area-inset-right: env(safe-area-inset-right, 0px);
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 20px);
    --safe-area-inset-left: env(safe-area-inset-left, 0px);

    /* Minimal & Neutral Palette */
    --app-bg: #F8F9FA;
    --card-bg: #FFFFFF;
    --text-primary: #111827;
    --text-secondary: #6B7280;
    --accent-primary: #2563EB;
    /* Blue Accent */
    --accent-warning: #EAB308;
    /* Yellow/Gold Accent */
    --accent-success: #16A34A;
    /* Green Accent */
    --border-color: #E5E7EB;
    --input-bg: #F9FAFB;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

/* --- CORE APP STRUCTURE --- */
html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    background: var(--app-bg);
    touch-action: manipulation;
}

html {
    height: -webkit-fill-available;
}

body {
    font-family: 'Inter', sans-serif;
    width: 100%;
    overflow: hidden;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app-container {
    width: 100%;
    max-width: 420px;
    height: calc(var(--vh, 1vh) * 100);
    margin: auto;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--app-bg);
}

.page-container {
    flex-grow: 1;
    position: relative;
    padding: calc(20px + var(--safe-area-inset-top)) 0;
    padding-bottom: calc(100px + var(--safe-area-inset-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.page {
    display: none;
    flex-direction: column;
    gap: 20px;
    padding: 0 20px;
}

.page.active-page {
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.page-header h1 {
    font-size: 1.8rem;
    margin: 0;
    font-weight: 700;
}

.page-header p {
    font-size: 1rem;
    color: var(--text-secondary);
    margin: 5px 0 0 0;
}

/* --- BOTTOM NAVIGATION BAR --- */
.app-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 420px;
    margin: auto;
    padding: 10px 0;
    padding-bottom: calc(10px + var(--safe-area-inset-bottom));
    display: flex;
    justify-content: space-around;
    z-index: 3;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-color);
}

.app-nav::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(-1px);
    height: calc(var(--safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.95);
    pointer-events: none;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 80px;
}

.nav-item i {
    font-size: 1.6rem;
    margin-bottom: 5px;
}

.nav-item.active {
    color: var(--accent-primary);
}

/* --- GLOBAL CARD STYLE --- */
.card {
    background: var(--card-bg);
    border-radius: 18px;
    padding: 25px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

/* --- DASHBOARD PAGE --- */
#dashboard-page {
    justify-content: center;
}

.status-card {
    text-align: center;
}

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

.client-name {
    font-size: 2rem;
    font-weight: 700;
    margin: 8px 0;
}

.timer-display {
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--accent-primary);
    letter-spacing: 2px;
    margin: 15px 0;
    transition: color 0.3s ease;
}

.status-card.paused-state {
    border-color: var(--accent-warning);
}

.paused-state .timer-display {
    color: var(--accent-warning);
}

.pause-btn,
.notes-btn {
    background: none;
    border: 2px solid var(--accent-warning);
    color: var(--accent-warning);
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 15px;
}

.notes-btn {
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.resume-btn {
    width: 100%;
    padding: 18px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 15px;
    color: var(--text-primary);
    background-color: var(--accent-warning);
    cursor: pointer;
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.client-links {
    display: flex;
    justify-content: center;
    gap: 15px;
    /* Reduced slightly to fit 3 items nicely */
    flex-wrap: wrap;
    /* Prevents breaking on very small phones */
    margin-bottom: 20px;
}

/* Update selector to include 'span' so the Notes button looks just like the links */
.client-links a,
.client-links span {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: opacity 0.2s;
}

.client-links a:hover,
.client-links span:hover {
    opacity: 0.8;
}

.task-description {
    margin: 24px 0 0 0;
    padding: 20px 10px 0 10px;
    border-top: 1px solid #E5E7EB;
    text-align: left;
    color: #4B5563;
    font-size: 14px;
    line-height: 1.6;

    /* THE MAGIC FOR TEXTBOXES */
    white-space: pre-wrap;
    word-wrap: break-word;

    width: 100%;
    box-sizing: border-box;
}

.task-description a {
    color: #1b6dfa;
    /* Matches your timer blue */
    text-decoration: none;
}


.swipe-container {
    width: 100%;
    height: 60px;
    background-color: #F3F4F6;
    border-radius: 30px;
    margin-top: 25px;
    position: relative;
    display: flex;
    align-items: center;
    overflow: hidden;
}

.swipe-container.swipe-disabled {
    opacity: 0.6;
    pointer-events: none;
}

.swipe-track {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    border-radius: 30px;
    background-color: var(--accent-primary);
    opacity: 0;
}

.swipe-handle {
    width: 54px;
    height: 54px;
    background-color: var(--card-bg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    position: absolute;
    left: 3px;
    top: 3px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--accent-primary);
    cursor: grab;
    z-index: 2;
    transition: transform 0.2s ease;
}

.swipe-handle i {
    font-size: 1.5rem;
}

.swipe-text {
    width: 100%;
    text-align: center;
    color: var(--text-secondary);
    font-weight: 600;
    z-index: 1;
    user-select: none;
}

/* --- TIMELINE & SELECTION (REFINED) --- */

/* Wrapper for the whole list */
.timeline-wrapper {
    background: var(--card-bg);
    /* White background for the list */
    border-radius: 18px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    padding: 5px 0;
    /* Minimal padding so items touch edges if needed */
    overflow: hidden;
}

.task-timeline-item {
    display: flex;
    position: relative;
    padding: 0;
    transition: background-color 0.2s ease;
    text-decoration: none;
    /* Remove defaults */
}

/* Left Column: Icon & Line */
.timeline-left {
    width: 50px;
    /* Fixed width for perfect alignment */
    position: relative;
    display: flex;
    justify-content: center;
    /* Horizontally center everything */
    flex-shrink: 0;
}

/* The Vertical Line */
.timeline-line {
    position: absolute;
    width: 2px;
    background-color: #E5E7EB;
    left: 50%;
    transform: translateX(-50%);
    top: 0;
    bottom: 0;
    z-index: 0;
}

/* Logic for First/Last Item Lines */
/* First item: Line starts from the center of the icon downwards */
.task-timeline-item:first-child .timeline-line {
    top: 24px;
    /* Matches roughly half the row height/icon center */
}

/* Last item: Line ends at the center of the icon */
.task-timeline-item:last-child .timeline-line {
    bottom: auto;
    height: 24px;
}

/* The Icon Circle */
.timeline-icon {
    position: relative;
    z-index: 1;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    margin-top: 12px;
    /* Push down to align with text title */
    border: 2px solid white;
    /* Creates a small gap feeling around the icon */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Right Column: Text Content */
.timeline-content {
    flex: 1;
    padding: 12px 15px 12px 0;
    /* Right padding, no left (gap handled by col) */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Typography */
.timeline-time-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.timeline-client {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* --- STATES --- */

/* Selected State */
.task-timeline-item.selected {
    background-color: #EFF6FF;
    /* Light Blue BG */
}

/* When selected, hide the border separator if you want a cleaner look */
.task-timeline-item.selected+.task-timeline-item {
    border-top-color: transparent;
}

/* Icon color changes */
.task-timeline-item.selected .timeline-icon {
    color: var(--accent-primary);
    background-color: white;
    box-shadow: 0 0 0 2px #BFDBFE;
    /* Blue ring */
}

/* Completed State */
.task-timeline-item.completed {
    opacity: 0.7;
}

.task-timeline-item.completed .timeline-icon {
    color: var(--accent-success);
    background-color: #ECFDF5;
    /* Light green bg for icon */
}

.task-timeline-item.completed .timeline-time-title {
    text-decoration: line-through;
    color: var(--text-secondary);
}

/* Interactive Hover */
.task-timeline-item.selectable:active {
    background-color: #F3F4F6;
}

/* Animations */
.fade-out {
    opacity: 0;
    transform: translateY(-5px);
    transition: all 0.2s;
}

.fade-in {
    animation: fadeInEffect 0.3s ease forwards;
}

@keyframes fadeInEffect {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- PROFILE PAGE --- */
.profile-header {
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
    padding-right: 50px;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid var(--accent-primary);
}

.profile-info h2 {
    margin: 0;
    font-size: 1.5rem;
}

.profile-info p {
    margin: 2px 0 0 0;
    color: var(--text-secondary);
    font-size: 1rem;
}

.card-header-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 15px;
    display: block;
}

.period-info {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.period-info .hours {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.period-info .label {
    color: var(--text-secondary);
    font-size: 1rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: #E5E7EB;
    border-radius: 4px;
    margin-top: 15px;
    overflow: hidden;
}

.progress-bar-inner {
    height: 100%;
    width: 0%;
    background-color: var(--accent-primary);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 15px;
    text-align: center;
}

.achievement {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.achievement .icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #F3F4F6;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.8rem;
    color: #9CA3AF;
    margin-bottom: 8px;
}

.achievement.unlocked .icon {
    background-color: #DBEAFE;
    color: var(--accent-primary);
}

.achievement .label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.resource-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.resource-list li a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 0;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
}

.resource-list li:not(:last-child) a {
    border-bottom: 1px solid var(--border-color);
}

.resource-list .fa-chevron-right,
.resource-list .fa-calendar-plus {
    color: var(--text-secondary);
}

.profile-actions-footer button {
    width: 100%;
    padding: 16px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    margin-bottom: 10px;
}

.btn-settings {
    background-color: var(--border-color);
    color: var(--text-primary);
    border: none;
}

.btn-logout {
    background: transparent;
    color: #DC2626;
    border: none;
}

.modal-content h2 {
    margin: 0 0 10px 0;
    font-size: 1.3rem;
}

.modal-content p {
    color: var(--text-secondary);
    margin: 0 0 15px 0;
    font-size: 0.95rem;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 25px;
}

.modal-btn {
    flex-grow: 1;
    padding: 14px;
    border-radius: 10px;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.modal-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-cancel {
    background-color: #F3F4F6;
    color: var(--text-primary);
}

.btn-save {
    background-color: var(--accent-primary);
    color: white;
}


/* --- MODAL SYSTEM (Shared Styles) --- */
#notes-modal-overlay,
#absence-modal-overlay,
#geofence-modal-overlay,
#shiftexchange-modal-overlay,
#storage-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;

    /* FIXED: Use opacity/visibility instead of display:none so transitions work */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#notes-modal-overlay.visible,
#absence-modal-overlay.visible,
#geofence-modal-overlay.visible,
#shiftexchange-modal-overlay.visible,
#storage-modal-overlay.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 18px;
    width: 90%;
    max-width: 420px;
    padding: 24px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.visible .modal-content {
    transform: scale(1);
}


/* --- MOBILE SPECIFIC OVERRIDES --- */
@media (max-width: 480px) {

    #notes-modal-overlay.visible,
    #absence-modal-overlay.visible,
    #storage-modal-overlay.visible,
    #shiftexchange-modal-overlay.visible {
        align-items: flex-end;
    }

    #notes-modal-overlay,
    #absence-modal-overlay,
    #storage-modal-overlay,
    #shiftexchange-modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    #notes-modal-overlay .modal-content,
    #absence-modal-overlay .modal-content,
    #storage-modal-overlay .modal-content,
    #shiftexchange-modal-overlay .modal-content {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 24px 24px 0 0;
        padding-bottom: calc(30px + var(--safe-area-inset-bottom));
        transform: translateY(100%);
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    }

    #notes-modal-overlay.visible .modal-content,
    #absence-modal-overlay.visible .modal-content,
    #storage-modal-overlay.visible .modal-content,
    #shiftexchange-modal-overlay.visible .modal-content {
        transform: translateY(0);
    }
}


/* --- NOTES MODAL SPECIFIC --- */
#notes-modal-textarea {
    width: 100%;
    height: 120px;
    box-sizing: border-box;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    margin-top: 5px;
    background-color: var(--input-bg);
}

/* --- ABSENCE MODAL SPECIFIC --- */
/* Form Elements Styling */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #374151;
    font-size: 0.9rem;
}

.form-input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    background-color: var(--input-bg);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    background-color: #FFF;
}

select.form-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236B7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 18px;
    padding-right: 45px;
}

textarea.form-input {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: flex;
    gap: 15px;
}

.form-row .form-group {
    flex: 1;
}

/* --- SKELETON LOADERS --- */

/* The base animation class */
.skeleton {
    background: #F3F4F6;
    background: linear-gradient(90deg,
            #F3F4F6 0%,
            #E5E7EB 50%,
            #F3F4F6 100%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite linear;
    border-radius: 6px;
    display: block;
}

@keyframes skeleton-shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Specific Shapes */
.sk-text {
    height: 1em;
    width: 100%;
    margin-bottom: 8px;
}

.sk-h1 {
    height: 32px;
    width: 60%;
    margin-bottom: 12px;
}

.sk-p {
    height: 16px;
    width: 40%;
    margin-bottom: 20px;
}

.sk-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
}

.sk-btn {
    height: 50px;
    width: 100%;
    border-radius: 12px;
    margin-top: 15px;
}

/* Dashboard Specific Skeletons */
.sk-dashboard-card {
    height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Profile Specific Skeletons */
.sk-profile-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
}

/* --- GEOFENCE WARNING MODAL --- */
#geofence-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    /* Slightly darker */
    z-index: 3000;
    /* Highest priority */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

#geofence-modal-overlay.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.geofence-icon {
    width: 60px;
    height: 60px;
    background-color: #FEF3C7;
    /* Yellow-100 */
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 15px auto;
    color: #D97706;
    /* Yellow-600 */
    font-size: 1.8rem;
}

.btn-warning-action {
    background-color: #D97706;
    /* Yellow-600 */
    color: white;
}

/* --- NEW FLOATING LANGUAGE SELECTOR --- */

.profile-lang-container {
    position: absolute;
    /* This aligns the top of the flag with the top of the avatar */
    top: 0;
    right: 0;
    z-index: 100;
}

/* The circular flag button - Removed all borders */
.lang-dropdown-btn {
    all: unset;
    /* Removes default button borders/bg */
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.lang-dropdown-btn:active {
    transform: scale(0.92);
}

/* Dropdown Menu */
.lang-dropdown-menu {
    position: absolute;
    top: 45px;
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    min-width: 150px;
    display: none;
    border: 1px solid #F3F4F6;
    overflow: hidden;
    padding: 6px 0;
    animation: langSlideIn 0.2s ease-out;
}

.lang-dropdown-menu.visible {
    display: block;
}

/* Individual items - CLEAN RESET */
.lang-dropdown-item {
    all: unset;
    /* Remove button borders and outlines */
    display: flex;
    align-items: center;
    width: calc(100% - 24px);
    /* Full width minus padding */
    padding: 10px 12px;
    gap: 12px;
    cursor: pointer;
    font-size: 15px;
    color: var(--text-primary);
    transition: background 0.2s;
}

.lang-dropdown-item:hover {
    background: #F9FAFB;
}

.lang-dropdown-item.active {
    background: #EFF6FF;
    color: var(--accent-primary);
    font-weight: 600;
}

/* Flag Image Formatting */
.flag-img {
    width: 34px;
    height: 34px;
    object-fit: cover;
    border-radius: 50%;
    /* Subtle light border to separate it from white backgrounds, but not black */
    border: 1px solid #F3F4F6;
}

.flag-img-small {
    width: 24px;
    height: 24px;
    object-fit: cover;
    border-radius: 50%;
    border: 1px solid #F3F4F6;
}

/* Checkmark positioning */
.lang-dropdown-item i.fa-check {
    margin-left: auto;
    /* Pushes to the far right */
    font-size: 0.85rem;
    color: var(--accent-primary);
}

@keyframes langSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- STORAGE PAGE --- */
#storage-page {
    align-items: center;
}

.storage-hero {
    text-align: center;
    padding: 30px 0;
}

.btn-scan-big {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), #1e40af);
    color: white;
    border: none;
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.4);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin: 0 auto;
}

.btn-scan-big:active {
    transform: scale(0.95);
    box-shadow: 0 5px 15px rgba(37, 99, 235, 0.3);
}

.btn-scan-big i {
    font-size: 3.5rem;
    margin-bottom: 10px;
}

.btn-scan-big span {
    font-size: 1.2rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* --- SCANNER OVERLAY --- */
#scanner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 5000;
}

#scanner-overlay.hidden {
    display: none !important;
}

#reader {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* Quagga Video styling */
#reader video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

/* Hide Quagga's debug canvas (red boxes) to keep our clean UI */
#reader canvas {
    display: none;
}

/* UI Layer remains the same */
.scanner-ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5002;
}

.scanner-close-btn {
    position: absolute;
    top: 75px;
    right: 20px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    pointer-events: auto;
    /* Re-enable clicks for button */
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.scanner-flash-btn {
    position: absolute;
    top: 75px;
    /* Aligned with close button */
    left: 20px;
    /* Top Left */
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
}

.scanner-flash-btn.active {
    background: rgba(255, 255, 255, 0.9);
    color: #F59E0B;
    /* Amber color when on */
    border-color: white;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
}

.scan-region-highlight {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 280px;
    height: 140px;
    border: 2px solid rgba(255, 255, 255, 0.7);
    border-radius: 12px;
    box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.6);
    /* Darkens the background */
}

.scan-laser {
    position: absolute;
    width: 100%;
    height: 2px;
    background: #ef4444;
    box-shadow: 0 0 6px #ef4444;
    top: 50%;
    animation: laserScan 2s infinite ease-in-out;
}

@keyframes laserScan {
    0% {
        top: 5%;
        opacity: 0;
    }

    20% {
        opacity: 1;
    }

    80% {
        opacity: 1;
    }

    100% {
        top: 95%;
        opacity: 0;
    }
}

/* --- STORAGE MODAL ACTIONS --- */
.product-image-large {
    width: 120px;
    height: 120px;
    border-radius: 12px;
    object-fit: cover;
    margin: 0 auto 15px auto;
    display: block;
    background-color: #F3F4F6;
}

/* --- QTY CONTROL --- */
.qty-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
}

.qty-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: white;
    font-size: 1.2rem;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.qty-btn:active {
    background-color: #F3F4F6;
    transform: scale(0.95);
}

/* The Native Picker disguised as a clean number */
select.qty-display {
    font-size: 1.8rem;
    font-weight: 700;
    width: 80px;
    text-align: center;
    text-align-last: center;
    /* Crucial for Chrome/iOS centering */
    border: none;
    background: transparent;
    appearance: none;
    /* Removes the default arrow */
    -webkit-appearance: none;
    color: var(--text-primary);
    padding: 0;
    outline: none;
    cursor: pointer;
}

/* Optional: Subtle indicator that it is clickable */
select.qty-display:focus {
    text-decoration: underline;
    text-decoration-color: var(--accent-primary);
}

.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}

.btn-action {
    padding: 15px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.btn-out {
    background: #FEE2E2;
    color: #DC2626;
}

.btn-in {
    background: #DCFCE7;
    color: #16A34A;
}

.btn-audit {
    background: #F3F4F6;
    color: #4B5563;
    grid-column: span 2;
}

/* --- Schedule Page New Styles --- */

.schedule-tabs {
    display: flex;
    background-color: #F3F4F6;
    padding: 4px;
    border-radius: 12px;
    margin-bottom: 10px;
}

.tab-btn {
    flex: 1;
    border: 1px solid #E5E7EB;
    background: white;
    padding: 10px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn.active {
    background-color: #E5E7EB;
    color: var(--text-primary);
    border: 1px solid #E5E7EB;
    font-weight: 600;
}

/* Date Group Header */
.date-group-header {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    font-weight: 600;
    margin: 20px 0 8px 0;
    position: sticky;
    top: 0;
    background: #FAFAF7;
    /* Match page background */
    padding: 5px 0;
    z-index: 5;
}

/* Task Item Card */
.schedule-task-item {
    background: white;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 15px;
}

.task-time {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    min-width: 90px;
}

.task-details {
    flex: 1;
    overflow: hidden;
}

.task-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-client {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Shift Exchange Modal Styles */
#shiftexchange-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#shiftexchange-modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e5e7eb;
}

.modal-close-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    color: #6b7280;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close-btn:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.shift-exchange-summary {
    margin-bottom: 24px;
}

.shift-summary-badge {
    padding: 16px;
    border-radius: 8px;
    background: #f9fafb;
}

.shift-summary-date {
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    color: #6b7280;
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

.shift-summary-time {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 8px;
}

.shift-summary-title {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 4px;
}

.shift-summary-client {
    font-size: 0.85rem;
    color: #6b7280;
}

.exchange-info-box {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    margin-bottom: 24px;
}

.exchange-info-box svg {
    flex-shrink: 0;
    margin-top: 2px;
}

.exchange-info-box strong {
    display: block;
    color: #1e40af;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.exchange-info-box p {
    margin: 0;
    color: #1e40af;
    font-size: 0.85rem;
    line-height: 1.5;
}

.btn-save svg {
    vertical-align: text-bottom;
}

/* Permission Request Dialog */
.permission-request-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    /* CHANGED: Hide by default */
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    /* CHANGED: Prevent blocking clicks when invisible */
}

.permission-request-overlay.visible {
    display: flex;
    opacity: 1;
    pointer-events: auto;
}


.permission-request-dialog {
    background: #fff;
    border-radius: 16px;
    max-width: 400px;
    width: 100%;
    padding: 32px 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

.permission-icon {
    font-size: 48px;
    text-align: center;
    margin-bottom: 16px;
}

.permission-request-dialog h2 {
    margin: 0 0 16px 0;
    font-size: 1.5rem;
    text-align: center;
    color: #1a1a1a;
}

.permission-request-dialog p {
    color: #4a5568;
    line-height: 1.6;
    margin-bottom: 16px;
    text-align: center;
}

.permission-request-dialog ul {
    margin: 16px 0;
    padding-left: 24px;
}

.permission-request-dialog li {
    color: #4a5568;
    margin-bottom: 8px;
    line-height: 1.5;
}

.privacy-note {
    background: #f7fafc;
    border-left: 3px solid #3b82f6;
    padding: 12px;
    border-radius: 4px;
    margin: 16px 0;
    text-align: left;
}

.permission-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.permission-actions button {
    flex: 1;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Permission Denied Dialog */
.permission-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    padding: 20px;
}

.permission-dialog {
    background: #fff;
    border-radius: 16px;
    max-width: 400px;
    width: 100%;
    padding: 32px 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.permission-dialog-header h3 {
    margin: 0 0 16px 0;
    font-size: 1.3rem;
    color: #1a1a1a;
}

.permission-dialog-body {
    color: #4a5568;
    line-height: 1.6;
}

.permission-instructions {
    background: #f7fafc;
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
}

.permission-instructions ol {
    margin: 0;
    padding-left: 20px;
}

.permission-instructions li {
    margin-bottom: 8px;
    color: #4a5568;
    line-height: 1.6;
}

.permission-dialog-actions {
    margin-top: 24px;
}

.permission-dialog-actions button {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    border: none;
}