/* ========================================
   PWA Styles - MontesCar
   ======================================== */

/* Touch-friendly interactions */
* {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    -webkit-touch-callout: none;
}

button, a, input, select, textarea {
    -webkit-tap-highlight-color: rgba(30, 64, 175, 0.2);
}

/* Safe area for notch devices */
body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* Pull to refresh indicator */
.ptr-indicator {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    background: white;
    padding: 0.5rem 1rem;
    border-radius: 0 0 1rem 1rem;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    transition: transform 0.3s ease;
    z-index: 9999;
}

.ptr-indicator.active {
    transform: translateX(-50%) translateY(0);
}

/* Offline indicator */
.offline-indicator {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #f59e0b;
    color: white;
    padding: 0.75rem;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 600;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 9999;
}

.offline-indicator.show {
    transform: translateY(0);
}

/* Loading states */
.skeleton {
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 0.5rem;
}

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

/* Card components */
.card-mobile {
    background: white;
    border-radius: 1rem;
    padding: 1.25rem;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    margin-bottom: 1rem;
}

.card-mobile:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
}

/* Bottom navigation for mobile */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e5e7eb;
    padding: 0.75rem 0;
    display: flex;
    justify-content: space-around;
    z-index: 100;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    text-decoration: none;
    color: #6b7280;
    font-size: 0.75rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.bottom-nav-item:active {
    background: #f3f4f6;
}

.bottom-nav-item.active {
    color: #1e40af;
}

.bottom-nav-icon {
    font-size: 1.5rem;
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 5rem;
    right: 1.5rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e40af, #1e3a8a);
    color: white;
    border: none;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 99;
}

.fab:active {
    transform: scale(0.9);
}

.fab:hover {
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.3);
}

/* Swipeable cards */
.swipeable-card {
    position: relative;
    transition: transform 0.3s ease;
}

.swipe-actions {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.swipeable-card.swiping .swipe-actions {
    opacity: 1;
}

.swipe-action-btn {
    width: 56px;
    height: 56px;
    border-radius: 0.75rem;
    border: none;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.swipe-action-btn.edit {
    background: #3b82f6;
}

.swipe-action-btn.delete {
    background: #ef4444;
}

/* Input fields mobile optimization */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="search"],
textarea,
select {
    font-size: 16px !important; /* Prevents zoom on iOS */
    -webkit-appearance: none;
    appearance: none;
}

/* File upload area */
.upload-area {
    border: 2px dashed #d1d5db;
    border-radius: 1rem;
    padding: 2rem 1rem;
    text-align: center;
    background: #f9fafb;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-area:hover {
    border-color: #1e40af;
    background: #eff6ff;
}

.upload-area.dragover {
    border-color: #1e40af;
    background: #eff6ff;
    transform: scale(1.02);
}

/* Image preview grid */
.image-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.image-preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 0.75rem;
    overflow: hidden;
    background: #f3f4f6;
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-remove {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    cursor: pointer;
}

/* Responsive grid */
.grid-responsive {
    display: grid;
    gap: 1rem;
}

@media (min-width: 640px) {
    .grid-responsive {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) {
    .grid-responsive {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .bottom-nav {
        display: none;
    }
    
    .fab {
        bottom: 2rem;
    }
}

@media (min-width: 1024px) {
    .grid-responsive {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Utility classes */
.hide-mobile {
    display: none;
}

@media (min-width: 768px) {
    .hide-mobile {
        display: block;
    }
    
    .hide-desktop {
        display: none;
    }
}

/* Touch feedback */
.touch-feedback {
    transition: all 0.1s ease;
}

.touch-feedback:active {
    transform: scale(0.95);
    opacity: 0.8;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.slide-up {
    animation: slideUp 0.3s ease;
}

/* Modal mobile */
.modal-mobile {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-mobile.show {
    opacity: 1;
    pointer-events: all;
}

.modal-content-mobile {
    background: white;
    border-radius: 1.5rem 1.5rem 0 0;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.modal-mobile.show .modal-content-mobile {
    transform: translateY(0);
}

@media (min-width: 768px) {
    .modal-mobile {
        align-items: center;
    }
    
    .modal-content-mobile {
        border-radius: 1.5rem;
        max-width: 600px;
        max-height: 80vh;
    }
}

/* Badge */
.badge-mobile {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-primary {
    background: #eff6ff;
    color: #1e40af;
}

.badge-success {
    background: #f0fdf4;
    color: #16a34a;
}

.badge-warning {
    background: #fef3c7;
    color: #d97706;
}

.badge-danger {
    background: #fee2e2;
    color: #dc2626;
}

/* Loading spinner */
.spinner {
    border: 3px solid #f3f4f6;
    border-top: 3px solid #1e40af;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    left: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

@media (min-width: 768px) {
    .toast-container {
        left: auto;
        width: 400px;
    }
}

.toast {
    background: white;
    border-radius: 0.75rem;
    padding: 1rem;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.2);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

.toast-success {
    border-left: 4px solid #10b981;
}

.toast-error {
    border-left: 4px solid #ef4444;
}

.toast-warning {
    border-left: 4px solid #f59e0b;
}

.toast-info {
    border-left: 4px solid #3b82f6;
}
