/* CSS Variables - Unified for all modules */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --light-bg: #ecf0f1;
    --card-shadow: 0 4px 6px rgba(0,0,0,0.1);
    --border-radius: 8px;
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    line-height: 1.6;
    color: #333;
    background-color: var(--light-bg);
    overflow-x: hidden;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header styles - unified for all modules */
.header {
    background: var(--primary-color);
    color: white;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.header-content > div:first-child {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
}

.header-content > div:last-child {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: rgba(255,255,255,0.2);
    border-radius: 15px;
    font-size: 0.8rem;
}

.status-indicator.online {
    color: #2ecc71;
}

.logout-btn {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 0.25rem 0.5rem;
    border-radius: 5px;
    text-decoration: none;
    transition: all 0.3s ease;
    font-size: 0.8rem;
}

.logout-btn:hover {
    background: rgba(255,255,255,0.3);
}

/* Navigation styles */
.admin-nav {
    background: white;
    padding: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-list {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-x: auto;
    white-space: nowrap;
}

.nav-item {
    position: relative;
    flex-shrink: 0;
}

.nav-link {
    display: block;
    padding: 1rem 1rem;
    color: var(--primary-color);
    text-decoration: none;
    transition: background 0.3s;
    border-bottom: 3px solid transparent;
    font-size: 0.9rem;
}

.nav-link:hover,
.nav-link.active {
    background: var(--light-bg);
    border-bottom-color: var(--secondary-color);
}

/* Main content */
.main-content {
    flex: 1;
    padding: 1rem 0;
}

.admin-container {
    max-width: 100%;
    margin: 1rem auto;
    padding: 0 1rem;
}

/* Professional tools */
.professional-tools {
    margin-bottom: 1.5rem;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.tool-card {
    background: white;
    padding: 1rem;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.tool-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.tool-card h3 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
    color: var(--primary-color);
}

.tool-card p {
    color: #7f8c8d;
    font-size: 0.8rem;
}

/* Chat container */
.chat-container {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.chat-messages {
    max-height: 300px;
    overflow-y: auto;
    padding: 1rem;
}

.message {
    margin-bottom: 0.75rem;
    display: flex;
    align-items: flex-start;
}

.message.user {
    justify-content: flex-end;
}

.message-content {
    max-width: 70%;
    padding: 0.75rem;
    border-radius: var(--border-radius);
    background: #f1f3f4;
    font-size: 0.9rem;
}

.message.bot .message-content {
    background: #e3f2fd;
    border: 1px solid #bbdefb;
}

.message.user .message-content {
    background: #e8f5e8;
    border: 1px solid #c8e6c9;
}

.message-content p {
    margin-bottom: 0.25rem;
}

.message-content p:last-child {
    margin-bottom: 0;
}

/* Typewriter cursor effect */
.typewriter-cursor::after {
    content: '|';
    animation: blink 1s infinite;
    color: var(--secondary-color);
    font-weight: bold;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.urgency-indicator {
    display: inline-block;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 0.25rem;
}

.urgency-rendah { background: #e8f5e8; color: #2e7d32; }
.urgency-sedang { background: #fff3e0; color: #f57c00; }
.urgency-tinggi { background: #fce4ec; color: #c2185b; }
.urgency-darurat { background: #ffebee; color: #d32f2f; }

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

/* Chat input */
.chat-input-container {
    padding: 0.75rem;
    border-top: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.chat-form {
    display: flex;
    gap: 0.25rem;
}

.input-group {
    display: flex;
    flex: 1;
    gap: 0.25rem;
}

#messageInput {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    transition: border-color 0.3s ease;
}

#messageInput:focus {
    outline: none;
    border-color: var(--secondary-color);
}

#sendButton {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color 0.3s ease;
    font-size: 0.9rem;
}

#sendButton:hover {
    background: #2980b9;
}

.send-icon {
    font-size: 1rem;
}

/* Quick actions */
.quick-actions {
    background: white;
    padding: 1rem;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
}

.quick-actions h3 {
    margin-bottom: 0.75rem;
    color: var(--primary-color);
    font-size: 1.1rem;
}

.action-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.5rem;
}

.quick-btn {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    padding: 0.5rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.8rem;
    text-align: center;
    white-space: nowrap;
}

.quick-btn:hover {
    background: #e3f2fd;
    border-color: var(--secondary-color);
    transform: translateY(-1px);
}

/* Footer */
.footer {
    background: var(--primary-color);
    color: white;
    padding: 1rem 0;
    margin-top: auto;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.footer-links {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.mode-switch {
    color: var(--secondary-color);
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--secondary-color);
    border-radius: var(--border-radius);
    transition: all 0.3s ease;
    font-size: 0.8rem;
}

.mode-switch:hover {
    background: var(--secondary-color);
    color: white;
    text-decoration: none;
}

/* Install button in header */
.install-btn-header {
    background: #27ae60;
    color: white;
    border: none;
    padding: 0.4rem 0.75rem;
    border-radius: var(--border-radius);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: 10px;
    display: none; /* Shown by PWA manager when ready */
}

.install-btn-header:hover {
    background: #219a52;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(39, 174, 96, 0.4);
}

.session-info {
    color: #2ecc71;
    font-size: 0.8rem;
}

/* Unlock page styles */
.unlock-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.unlock-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem;
}

.unlock-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    max-width: 400px;
    width: 100%;
}

.unlock-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.unlock-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
    color: var(--primary-color);
}

.unlock-header p {
    color: #7f8c8d;
    font-size: 0.9rem;
}

.unlock-form {
    margin-bottom: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    transition: border-color 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--secondary-color);
}

.unlock-btn {
    width: 100%;
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.unlock-btn:hover {
    transform: translateY(-2px);
    background: #2980b9;
}

.unlock-footer {
    text-align: center;
    color: #7f8c8d;
}

.unlock-footer p {
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
}

.back-link {
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

.back-link:hover {
    text-decoration: underline;
}

/* Error messages */
.error-message {
    background: #ffebee;
    color: #c62828;
    padding: 0.75rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    border: 1px solid #ffcdd2;
    font-size: 0.9rem;
}

.alert {
    padding: 0.75rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-success {
    background: #e8f5e8;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.alert-danger {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

.alert-info {
    background: #e3f2fd;
    color: #1976d2;
    border: 1px solid #bbdefb;
}

/* Loading state */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Badge styles */
.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

.badge-warga { background: #e3f2fd; color: #1976d2; }
.badge-nakes { background: #ffebee; color: #c62828; }

/* Button styles */
.btn {
    padding: 0.5rem 0.75rem;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    font-size: 0.85rem;
    transition: all 0.3s;
    white-space: nowrap;
}

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

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Data table styles */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}

.data-table th {
    background: var(--light-bg);
    font-weight: 600;
    color: var(--primary-color);
}

.data-table tbody tr:hover {
    background: #f8f9fa;
}

/* Content section */
.content-section {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    margin-bottom: 1.5rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--light-bg);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.section-title {
    font-size: 1.1rem;
    color: var(--primary-color);
    margin: 0;
}

/* Dashboard grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 1rem;
    box-shadow: var(--card-shadow);
    text-align: center;
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-3px);
}

.stat-number {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--secondary-color);
    margin-bottom: 0.25rem;
}

.stat-label {
    color: #7f8c8d;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Action card */
.action-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 1rem;
    text-align: center;
    box-shadow: var(--card-shadow);
    text-decoration: none;
    color: inherit;
    transition: all 0.3s;
    display: block;
}

.action-card:hover {
    transform: translateY(-2px);
    text-decoration: none;
    color: inherit;
}

.action-icon {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    width: 95%;
    max-width: 500px;
}

.close {
    color: #aaa;
    float: right;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: black;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 0 0.75rem;
    }

    .header h1 {
        font-size: 1.2rem;
    }

    .header-content {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    .tool-grid {
        grid-template-columns: 1fr;
    }

    .message-content {
        max-width: 85%;
    }

    .action-buttons {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        justify-content: center;
    }

    .footer-content {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    .footer-links {
        justify-content: center;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .stat-card {
        padding: 0.75rem;
    }

    .stat-number {
        font-size: 1.25rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }

    .content-section {
        padding: 1rem;
    }

    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .section-title {
        font-size: 1rem;
    }

    .btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }

    .data-table {
        font-size: 0.8rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.3rem;
    }

    .action-card {
        padding: 0.75rem;
    }

    .action-icon {
        font-size: 1.25rem;
    }

    .modal-content {
        padding: 1rem;
        margin: 10% auto 5% auto;
        width: 95%;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 1rem 0;
    }

    .header h1 {
        font-size: 1.1rem;
    }

    .main-content {
        padding: 0.75rem 0;
    }

    .chat-messages {
        max-height: 250px;
        padding: 0.75rem;
    }

    .quick-actions {
        padding: 0.75rem;
    }

    .unlock-card {
        padding: 1rem;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: 0.5rem;
    }

    .stat-number {
        font-size: 1.1rem;
    }

    .stat-label {
        font-size: 0.7rem;
    }

    .data-table {
        font-size: 0.75rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.2rem;
    }

    .action-card {
        padding: 0.5rem;
    }

    .action-icon {
        font-size: 1rem;
    }

    .modal-content {
        padding: 0.75rem;
    }

    .form-group {
        margin-bottom: 0.75rem;
    }

    .form-group label {
        font-size: 0.85rem;
    }

    .form-control {
        font-size: 0.85rem;
    }
}

/* Scrollable tables on mobile */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Follow-up question styles */
.followup-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.followup-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: 600;
    min-width: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.followup-btn:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.followup-btn:active {
    transform: translateY(0);
}

/* Responsive follow-up buttons */
@media (max-width: 480px) {
    .followup-buttons {
        flex-direction: column;
        gap: 0.75rem;
    }

    .followup-btn {
        width: 100%;
        padding: 1rem;
        font-size: 1rem;
    }
}

/* ========================================
   PWA Styles
   ======================================== */

/* Install Prompt */
.pwa-install-prompt {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    padding: 1rem;
    max-width: 400px;
    width: 90%;
    z-index: 9999;
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}

.pwa-install-prompt.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.pwa-install-prompt.hidden {
    transform: translateX(-50%) translateY(100px);
    opacity: 0;
}

.install-prompt-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
}

.install-prompt-icon {
    font-size: 2.5rem;
    flex-shrink: 0;
}

.install-prompt-text {
    flex: 1;
}

.install-prompt-text strong {
    display: block;
    color: var(--primary-color);
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.install-prompt-text p {
    color: #7f8c8d;
    font-size: 0.85rem;
    margin: 0;
}

.install-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.3s ease;
    flex-shrink: 0;
}

.install-btn:hover {
    background: #2980b9;
}

.dismiss-install-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #f1f3f4;
    color: #666;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.dismiss-install-btn:hover {
    background: #e0e0e0;
}

/* Offline Notification */
.offline-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: #fff3e0;
    border: 1px solid #ffe0b2;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    max-width: 90%;
    width: 400px;
}

.offline-notification.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.offline-notification.hidden {
    transform: translateX(-50%) translateY(-100px);
    opacity: 0;
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.notification-icon {
    font-size: 1.5rem;
}

.notification-text {
    color: #e65100;
    font-size: 0.9rem;
    flex: 1;
}

/* Update Notification */
.update-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #e3f2fd;
    border: 1px solid #bbdefb;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    max-width: 90%;
    width: 400px;
}

.update-notification .notification-content {
    justify-content: space-between;
}

.reload-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.3s ease;
}

.reload-btn:hover {
    background: #2980b9;
}

/* Queued Requests Indicator */
.queued-indicator {
    position: fixed;
    top: 80px;
    right: 20px;
    background: #ff9800;
    color: white;
    border-radius: 20px;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 999;
    font-size: 0.85rem;
    animation: pulse-queued 2s infinite;
}

@keyframes pulse-queued {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.queued-icon {
    font-size: 1rem;
}

.queued-count {
    background: white;
    color: #ff9800;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
}

/* Online/Offline Status Styles */
.status-indicator.offline {
    color: #e74c3c;
}

.status-indicator.online {
    color: #2ecc71;
}

/* Body classes for online/offline modes */
body.offline-mode {
    opacity: 0.95;
}

body.offline-mode .chat-input-container {
    opacity: 0.7;
}

body.offline-mode .quick-actions {
    opacity: 0.8;
}

/* Safe area insets for notched devices */
@supports (padding: max(0px)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .header,
    .footer {
        padding-left: max(1.5rem, env(safe-area-inset-left));
        padding-right: max(1.5rem, env(safe-area-inset-right));
    }

    .pwa-install-prompt,
    .offline-notification,
    .update-notification {
        left: max(50%, env(safe-area-inset-left));
        width: min(90%, 400px);
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .pwa-install-prompt,
    .offline-notification,
    .update-notification {
        border-width: 2px;
    }

    .install-btn,
    .reload-btn {
        border: 2px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .pwa-install-prompt,
    .offline-notification,
    .update-notification {
        transition: none;
    }

    @keyframes pulse-queued {
        0%, 100% { transform: scale(1); }
        50% { transform: scale(1); }
    }
}

/* Dark mode support (future enhancement) */
@media (prefers-color-scheme: dark) {
    .pwa-install-prompt,
    .offline-notification,
    .update-notification {
        background: #2c3e50;
        color: #ecf0f1;
    }

    .install-prompt-text strong {
        color: #ecf0f1;
    }

    .install-prompt-text p {
        color: #bdc3c7;
    }

    .dismiss-install-btn {
        background: #34495e;
        color: #ecf0f1;
    }

    .dismiss-install-btn:hover {
        background: #4a6278;
    }
}

/* Print styles - hide PWA elements */
@media print {
    .pwa-install-prompt,
    .offline-notification,
    .update-notification,
    .queued-indicator {
        display: none !important;
    }
}