/* === UX IMPROVEMENTS - TOAST NOTIFICATIONS === */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-radius: 10px;
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: auto;
    max-width: 350px;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-success { border-left: 4px solid #28a745; }
.toast-error { border-left: 4px solid #dc3545; }
.toast-warning { border-left: 4px solid #ffc107; }
.toast-info { border-left: 4px solid #17a2b8; }

.toast .material-symbols-rounded {
    font-size: 20px;
}

.toast-success .material-symbols-rounded { color: #28a745; }
.toast-error .material-symbols-rounded { color: #dc3545; }
.toast-warning .material-symbols-rounded { color: #ffc107; }
.toast-info .material-symbols-rounded { color: #17a2b8; }

.toast-message {
    font-size: 14px;
    color: var(--fg);
}

/* === UX IMPROVEMENTS - LOADING SPINNER === */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.loading-overlay.show {
    opacity: 1;
    visibility: visible;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 30px;
    background: var(--card);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-message {
    font-size: 14px;
    color: var(--fg);
}

/* === UX IMPROVEMENTS - PULL TO REFRESH === */
.pull-indicator {
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 10px 20px;
    background: var(--card);
    border-radius: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 100;
}

.pull-indicator.ready {
    background: var(--primary);
    color: #fff;
}

.pull-indicator.ready .material-symbols-rounded {
    color: #fff;
}

.pull-indicator.loading .material-symbols-rounded {
    animation: spin 1s linear infinite;
}

.pull-text {
    font-size: 12px;
    white-space: nowrap;
}

/* === UX IMPROVEMENTS - QUICK ACTIONS MENU === */
.quick-actions-menu {
    position: fixed;
    background: var(--card);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    padding: 8px;
    z-index: 1000;
    opacity: 0;
    transform: scale(0.9);
    transition: all 0.2s ease;
}

.quick-actions-menu.show {
    opacity: 1;
    transform: scale(1);
}

.quick-action {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 14px;
    color: var(--fg);
    cursor: pointer;
    transition: background 0.2s;
}

.quick-action:hover {
    background: var(--bg);
}

.quick-action.danger {
    color: #dc3545;
}

.quick-action .material-symbols-rounded {
    font-size: 20px;
}

/* === UX IMPROVEMENTS - TEMPLATE PICKER === */
.template-picker {
    background: var(--card);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    max-width: 300px;
    max-height: 300px;
    overflow: hidden;
    z-index: 1000;
}

.template-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 14px;
}

.template-picker-items {
    padding: 8px;
    max-height: 240px;
    overflow-y: auto;
}

.template-item {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 13px;
    color: var(--fg);
    cursor: pointer;
    text-align: left;
    transition: background 0.2s;
}

.template-item:hover {
    background: var(--bg);
}

/* === UX IMPROVEMENTS - OFFLINE INDICATOR === */
.offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px;
    background: #dc3545;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    z-index: 10001;
}

.offline-indicator.show {
    transform: translateY(0);
}

.offline-indicator .material-symbols-rounded {
    font-size: 18px;
}

/* === UX IMPROVEMENTS - AUTOSAVE INDICATOR === */
.autosave-indicator {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.autosave-indicator.saving,
.autosave-indicator.saved {
    opacity: 1;
}

.autosave-indicator.saving {
    background: var(--primary);
    color: #fff;
}

.autosave-indicator.saved {
    background: #28a745;
    color: #fff;
}

.autosave-indicator.fade-out {
    opacity: 0;
}

/* === UX IMPROVEMENTS - PROGRESS INDICATOR === */
.progress-indicator {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--card);
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 200px;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.progress-indicator.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
}

/* === UX IMPROVEMENTS - VOICE INPUT === */
.voice-active {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.2) !important;
}

.voice-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.voice-btn:hover {
    background: var(--primary);
    color: #fff;
}

.voice-btn.active {
    background: #dc3545;
    color: #fff;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(220, 53, 69, 0); }
}

/* === UX IMPROVEMENTS - VOICE CONTROL BUTTON === */
.voice-control-btn {
    position: fixed;
    bottom: 100px;
    left: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #0066cc);
    color: #fff;
    border: none;
    box-shadow: 0 4px 15px rgba(0, 91, 127, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 999;
}

.voice-control-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 91, 127, 0.4);
}

.voice-control-btn.active {
    background: linear-gradient(135deg, #dc3545, #c82333);
    animation: voice-pulse 1.5s infinite;
}

@keyframes voice-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4); }
    50% { box-shadow: 0 0 0 15px rgba(220, 53, 69, 0); }
}

.voice-control-btn .material-symbols-rounded {
    font-size: 28px;
}

.voice-btn-bottom-left {
    bottom: 100px;
    left: 20px;
}

.voice-btn-bottom-right {
    bottom: 100px;
    right: 20px;
    left: auto;
}

/* Voice Help Dialog */
.voice-help {
    padding: 16px;
}

.voice-help h4 {
    margin: 16px 0 8px 0;
    color: var(--fg);
    font-size: 14px;
    font-weight: 600;
}

.voice-help h4:first-child {
    margin-top: 0;
}

.voice-help ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.voice-help li {
    padding: 8px 12px;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 6px;
    font-size: 14px;
    color: var(--fg);
}

/* === UX IMPROVEMENTS - ACCESSIBILITY === */
@media (pointer: coarse) {
    /* Increase touch targets on touch devices */
    button, .btn, .icon-btn, .vtab, .htab {
        min-height: 44px;
        min-width: 44px;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        min-height: 44px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Focus indicators for keyboard navigation */
button:focus-visible,
.btn:focus-visible,
.icon-btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border: #000;
        --muted: #333;
    }
    
    .toast, .loading-spinner, .quick-actions-menu, .template-picker {
        border: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* === UX IMPROVEMENTS - STATUS COLORS === */
.status-critical { color: #dc3545; }
.status-warning { color: #ffc107; }
.status-stable { color: #28a745; }
.status-improved { color: #17a2b8; }
.status-discharged { color: #6c757d; }

.status-bg-critical { background: rgba(220, 53, 69, 0.1); border-left: 3px solid #dc3545; }
.status-bg-warning { background: rgba(255, 193, 7, 0.1); border-left: 3px solid #ffc107; }
.status-bg-stable { background: rgba(40, 167, 69, 0.1); border-left: 3px solid #28a745; }
.status-bg-improved { background: rgba(23, 162, 184, 0.1); border-left: 3px solid #17a2b8; }

/* === UX IMPROVEMENTS - BOTTOM SHEETS === */
.bottom-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.bottom-sheet-overlay.show {
    opacity: 1;
    visibility: visible;
}

.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 90vh;
    background: var(--card);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.2);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.bottom-sheet.show {
    transform: translateY(0);
}

.bottom-sheet.fullscreen {
    max-height: 100vh;
    border-radius: 0;
}

.bottom-sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 12px auto;
    cursor: grab;
    flex-shrink: 0;
}

.bottom-sheet-handle:active {
    cursor: grabbing;
}

.bottom-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.bottom-sheet-header-content {
    flex: 1;
    min-width: 0;
}

.bottom-sheet-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--fg);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.bottom-sheet-icon {
    font-size: 20px;
    color: var(--text-sec);
}

.bottom-sheet-subtitle {
    display: block;
    font-size: 13px;
    color: var(--text-sec);
    margin-top: 2px;
}

.bottom-sheet-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    transition: all 0.2s;
}

.bottom-sheet-close:hover {
    background: var(--primary);
    color: #fff;
}

.bottom-sheet-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.bottom-sheet-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}

.bottom-sheet-footer .btn {
    flex: 1;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.bottom-sheet-footer .btn-primary {
    background: var(--primary);
    color: #fff;
}

.bottom-sheet-footer .btn-primary:hover {
    filter: brightness(1.1);
}

.bottom-sheet-footer .btn-secondary {
    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--border);
}

/* Bottom Sheet Animations */
@keyframes bottomSheetSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

@keyframes bottomSheetSlideDown {
    from { transform: translateY(0); }
    to { transform: translateY(100%); }
}

.bottom-sheet.show {
    animation: bottomSheetSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.bottom-sheet.closing {
    animation: bottomSheetSlideDown 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* === UX IMPROVEMENTS - FLOATING ACTION BUTTON (FAB) === */
.fab-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 900;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 12px;
}

/* FAB inside modal - position relative to modal */
.modal-overlay .fab-container,
.sheet .fab-container {
    position: absolute;
    z-index: 1000;
}

.fab-main {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    border: none;
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 901;
}

.fab-main:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.fab-main:active {
    transform: scale(0.95);
}

.fab-main.open {
    transform: rotate(45deg);
    border-radius: 50%;
}

.fab-main .material-symbols-rounded {
    font-size: 28px;
    transition: transform 0.3s;
}

.fab-main.open .material-symbols-rounded {
    transform: rotate(-45deg);
}

/* FAB Speed Dial Items */
.fab-item {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    border: none;
    background: var(--card);
    color: var(--fg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0) translateY(20px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    pointer-events: auto;
    z-index: 10;
}

.fab-container.open .fab-item {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

.fab-container.open .fab-item {
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* Staggered animation for fab items */
.fab-container.open .fab-item:nth-child(2) { transition-delay: 0.05s; }
.fab-container.open .fab-item:nth-child(3) { transition-delay: 0.1s; }
.fab-container.open .fab-item:nth-child(4) { transition-delay: 0.15s; }
.fab-container.open .fab-item:nth-child(5) { transition-delay: 0.2s; }

.fab-item:hover {
    background: var(--primary);
    color: #fff;
    transform: scale(1.1);
}

.fab-item .material-symbols-rounded {
    font-size: 24px;
}

/* FAB Labels */
.fab-label {
    position: absolute;
    right: 60px;
    background: var(--card);
    color: var(--fg);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.2s;
    pointer-events: none;
}

.fab-item:hover .fab-label {
    opacity: 1;
    transform: translateX(0);
}

/* FAB Backdrop */
.fab-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 899;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.fab-backdrop.show {
    opacity: 1;
    visibility: visible;
}

/* FAB on Mobile */
@media (max-width: 768px) {
    .fab-container {
        bottom: 16px;
        right: 16px;
    }
    
    .fab-main {
        width: 52px;
        height: 52px;
    }
    
    .fab-item {
        width: 44px;
        height: 44px;
    }
}

/* === UX IMPROVEMENTS - SWIPE ACTIONS === */
.swipe-container {
    position: relative;
    overflow: hidden;
}

.swipe-item {
    position: relative;
    transition: transform 0.2s ease;
    touch-action: pan-y;
    background: var(--card);
}

.swipe-actions {
    position: absolute;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    overflow: hidden;
}

.swipe-actions-left {
    right: 100%;
    margin-right: -1px;
}

.swipe-actions-right {
    left: 100%;
    margin-left: -1px;
}

.swipe-action {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-width: 80px;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.swipe-action .material-symbols-rounded {
    font-size: 24px;
    margin-bottom: 4px;
}

.swipe-action-complete {
    background: #28a745;
}

.swipe-action-delete {
    background: #dc3545;
}

.swipe-action-edit {
    background: #17a2b8;
}

.swipe-action-archive {
    background: #6c757d;
}

/* Swipe indicator dots */
.swipe-hint {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 4px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.swipe-hint-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--muted);
}

/* Task item swipe styling */
.task-item.swipeable {
    position: relative;
    background: var(--card);
    border-radius: 8px;
    margin-bottom: 8px;
    overflow: hidden;
}

.task-item.swipeable .swipe-content {
    padding: 12px 16px;
    background: var(--card);
    position: relative;
    z-index: 1;
}

/* === UX IMPROVEMENTS - TASK SWIPE STATES === */
.task-swipe-left {
    transform: translateX(-80px);
}

.task-swipe-right {
    transform: translateX(80px);
}

.task-swipe-complete {
    background: rgba(40, 167, 69, 0.1) !important;
}

.task-swipe-delete {
    background: rgba(220, 53, 69, 0.1) !important;
}
