:root {
    --ios-blue: #007AFF;
    --ios-gray: #8E8E93;
    --ios-light-gray: #F2F2F7;
    --ios-bg: #FFFFFF;
    --ios-text: #000000;
    --ios-red: #FF3B30;
    --ios-green: #34C759;
    --ios-orange: #FF9500;
    --shadow: 0 8px 24px rgba(0,0,0,0.06);
    --safe-top: env(safe-area-inset-top);
    --safe-bottom: env(safe-area-inset-bottom);
}

/* Base Adjustments for native feel */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    background-color: var(--ios-light-gray);
    color: var(--ios-text);
    overflow: hidden;
    position: fixed; /* Prevents elastic scrolling on body */
    width: 100%;
    -webkit-user-select: none; /* iOS Native feel */
}

#app {
    height: 100%;
    position: relative;
}

.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--ios-light-gray);
    display: none;
    flex-direction: column;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
}

.view.active {
    display: flex;
}

/* Spring Animations */
@keyframes spring {
    0% { transform: scale(1); }
    50% { transform: scale(0.96); }
    100% { transform: scale(1); }
}

.tap-active {
    animation: spring 0.2s ease-out;
}

/* Improved Header */
header {
    background: rgba(249, 249, 249, 0.94);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    padding: 12px 16px;
    padding-top: calc(8px + var(--safe-top));
    border-bottom: 0.5px solid rgba(0,0,0,0.2);
    z-index: 100;
}

h1 {
    font-size: 32px;
    letter-spacing: -1px;
}

/* List Item Enhancements */
.list-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: white;
    position: relative;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border-bottom: 0.5px solid var(--ios-light-gray);
}

.list-item:active {
    background-color: #E5E5EA;
}

.checkbox {
    width: 26px;
    height: 26px;
    border: 1.5px solid #C7C7CC;
    border-radius: 50%;
    margin-right: 14px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Swipe UI Improvements */
.swipe-actions {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    display: flex;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.swipe-btn {
    width: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 13px;
    font-weight: 600;
}

.btn-delete { background: var(--ios-red); }
.btn-edit { background: var(--ios-gray); }

/* Pull-to-refresh visual */
.ptr-element {
    position: absolute;
    top: -50px;
    left: 0;
    width: 100%;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ios-gray);
    transition: transform 0.2s;
}

/* FAB - Floating Action Button (Apple Notes Style) */
.fab {
    bottom: calc(40px + var(--safe-bottom));
    right: 24px;
    background: white;
    color: var(--ios-blue);
    width: 56px;
    height: 56px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    font-size: 28px;
}

/* Login */
#view-login {
    justify-content: center;
    align-items: center;
    background: var(--ios-bg);
}

.login-container {
    text-align: center;
    width: 100%;
    max-width: 320px;
}

.pin-input-wrapper {
    margin: 40px 0;
}

#input-login-pin {
    background: var(--ios-light-gray);
    border: none;
    border-radius: 12px;
    padding: 20px;
    font-size: 32px;
    text-align: center;
    letter-spacing: 15px;
    width: 200px;
    font-weight: 700;
    color: var(--ios-text);
}

#input-login-pin:focus {
    outline: 2px solid var(--ios-blue);
}

#input-login-pin::placeholder {
    letter-spacing: 5px;
    color: #C7C7CC;
}

/* PWA Prompt */
@keyframes slideUp {
    from { transform: translateY(150%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.pwa-prompt {
    position: fixed;
    bottom: 30px;
    left: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 18px;
    padding: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.25);
    z-index: 9999;
    display: none;
    border: 0.5px solid rgba(0,0,0,0.1);
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.pwa-prompt-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.pwa-prompt-icon {
    font-size: 30px;
}

.pwa-prompt-text {
    flex: 1;
    font-size: 14px;
}

.pwa-prompt-text strong {
    display: block;
    font-size: 16px;
    margin-bottom: 4px;
}

.pwa-prompt-text p {
    margin: 0;
    color: var(--ios-gray);
}

.ios-share-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23007AFF' viewBox='0 0 24 24'%3E%3Cpath d='M12 5V19M12 5L7 10M12 5L17 10M5 12V21H19V12' stroke='%23007AFF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center;
    vertical-align: middle;
    margin: 0 2px;
}

.pwa-prompt button {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--ios-gray);
    padding: 5px;
}

/* Modals - Native Sheet look */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: white;
    width: 100%;
    max-width: 500px;
    border-radius: 20px 20px 0 0; /* Bottom sheet style */
    padding: 24px;
    position: fixed;
    bottom: 0;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal h3 {
    margin-top: 0;
}

.modal input, .modal select {
    width: 100%;
    padding: 12px;
    margin: 8px 0;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-actions button {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
}

.primary {
    background: var(--ios-blue);
    color: white;
}

/* Admin Styles */
.admin-section {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.admin-section h2 {
    font-size: 18px;
    margin-top: 0;
    margin-bottom: 16px;
}

.secondary-btn {
    width: 100%;
    padding: 10px;
    background: none;
    border: 1px solid var(--ios-blue);
    color: var(--ios-blue);
    border-radius: 8px;
    font-weight: 600;
    margin-top: 10px;
}

.danger-btn {
    width: 100%;
    padding: 12px;
    background: var(--ios-red);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
}

.user-row, .store-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--ios-light-gray);
}

.user-row:last-child, .store-row:last-child {
    border-bottom: none;
}

.error-msg {
    color: var(--ios-red);
    margin-top: 10px;
    font-size: 14px;
}
