/**
 * Yolti Rutas - App Styles
 */

/* Base */
:root {
    --primary: #432a18;
    --primary-light: #fff9f0;
    --bg: #faf8f5;
}

* {
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
}

body {
    font-family: 'Rethink Sans', system-ui, -apple-system, sans-serif;
    background-color: var(--bg);
    color: var(--primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Safe Areas */
.safe-area-top {
    padding-top: env(safe-area-inset-top, 0px);
}

.safe-area-bottom {
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Touch */
.touch-manipulation {
    touch-action: manipulation;
}

/* Animations */
@keyframes slide-up {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.animate-slide-up {
    animation: slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.animate-fade-in {
    animation: fade-in 0.2s ease-out;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(67, 42, 24, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(67, 42, 24, 0.3);
}

/* Form Elements */
input,
textarea,
select {
    font-family: inherit;
}

input:disabled,
textarea:disabled,
select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23432a18' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 24px;
    padding-right: 48px;
}

/* Modal Overlay */
#modal-backdrop {
    transition: opacity 0.2s ease;
}

#modal-container.hidden #modal-backdrop {
    opacity: 0;
}

/* Cards */
.card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(67, 42, 24, 0.1);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: rgb(220, 252, 231);
    color: rgb(21, 128, 61);
}

.badge-warning {
    background: rgb(254, 243, 199);
    color: rgb(180, 83, 9);
}

.badge-error {
    background: rgb(254, 226, 226);
    color: rgb(185, 28, 28);
}

.badge-info {
    background: rgb(219, 234, 254);
    color: rgb(29, 78, 216);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 500;
    transition: all 0.15s ease;
    cursor: pointer;
    border: none;
    background: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-outline {
    background: transparent;
    border: 1px solid rgba(67, 42, 24, 0.2);
    color: var(--primary);
}

.btn-outline:hover {
    background: rgba(67, 42, 24, 0.05);
}

.btn-soft {
    background: rgb(67 42 24 / 0.05);
    border: none;
    color: var(--primary);
}

.btn-soft:hover {
    background: rgb(67 42 24 / 0.1);
}

/* Progress Bar */
.progress-bar {
    height: 8px;
    background: rgba(67, 42, 24, 0.1);
    border-radius: 9999px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
}

.empty-state svg {
    width: 64px;
    height: 64px;
    color: rgba(67, 42, 24, 0.3);
    margin-bottom: 16px;
}

/* Navigation Active State */
.nav-item.active {
    background: rgba(67, 42, 24, 0.1);
    color: var(--primary);
}

.nav-item:not(.active) {
    color: rgba(67, 42, 24, 0.4);
}

/* Toast (optional) */
.toast {
    position: fixed;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    border-radius: 12px;
    font-weight: 500;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 100;
}

/* PWA Install Banner (optional) */
.pwa-install-banner {
    position: fixed;
    bottom: 100px;
    left: 16px;
    right: 16px;
    background: white;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 45;
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Hide when printing */
@media print {

    #bottom-nav,
    #fab-btn {
        display: none !important;
    }

    #main-content {
        padding: 0 !important;
    }
}

/* ========== Bottom Sheet ========== */
.bottom-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 50;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.bottom-sheet-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 24px 24px 0 0;
    z-index: 51;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
        height 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 95vh;
    display: flex;
    flex-direction: column;
}

.bottom-sheet.active {
    transform: translateY(0);
}

.bottom-sheet.expanded {
    height: 95vh !important;
    border-radius: 0;
}

.bottom-sheet-handle {
    width: 40px;
    height: 5px;
    background: rgba(67, 42, 24, 0.2);
    border-radius: 3px;
    margin: 12px auto 8px;
    cursor: grab;
}

.bottom-sheet-handle:active {
    cursor: grabbing;
}

.bottom-sheet-header {
    padding: 0 20px 16px;
    border-bottom: 1px solid rgba(67, 42, 24, 0.1);
    flex-shrink: 0;
}

.bottom-sheet-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    overscroll-behavior: contain;
}

.bottom-sheet-footer {
    padding: 16px 20px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid rgba(67, 42, 24, 0.1);
    background: white;
    flex-shrink: 0;
}

/* ========== Checkbox Custom ========== */
.checkbox-custom {
    width: 22px;
    height: 22px;
    border: 2px solid rgba(67, 42, 24, 0.3);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    flex-shrink: 0;
    cursor: pointer;
}

.checkbox-custom.checked {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox-custom.checked svg {
    color: white;
}

.checkbox-custom:not(.checked) svg {
    display: none;
}

/* ========== Toggle Switch ========== */
.toggle-container {
    display: flex;
    background: rgba(67, 42, 24, 0.1);
    border-radius: 12px;
    padding: 4px;
}

.toggle-btn {
    flex: 1;
    padding: 10px 16px;
    border-radius: 10px;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    border: none;
    background: none;
    color: rgba(67, 42, 24, 0.6);
}

.toggle-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ========== Filter Chips ========== */
.filter-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.filter-chips::-webkit-scrollbar {
    display: none;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    border: 1px solid rgba(67, 42, 24, 0.2);
    background: white;
    color: rgba(67, 42, 24, 0.7);
    transition: all 0.15s ease;
}

.filter-chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.filter-chip .count {
    background: rgba(67, 42, 24, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
}

.filter-chip.active .count {
    background: rgba(255, 255, 255, 0.2);
}

/* ========== Store Selection Card ========== */
.store-select-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    background: white;
    border: 1px solid rgba(67, 42, 24, 0.1);
    border-radius: 14px;
    transition: all 0.15s ease;
    cursor: pointer;
}

.store-select-card:active {
    transform: scale(0.98);
}

.store-select-card.selected {
    border-color: var(--primary);
    background: rgba(67, 42, 24, 0.03);
}

.store-select-card.type-cobro {
    border-left: 4px solid #f97316;
}

.store-select-card.type-resurtido {
    border-left: 4px solid var(--primary);
}

.store-select-card.type-prospecto {
    border-left: 4px solid #9333ea;
}

/* ========== Map Container ========== */
.map-container {
    width: 100%;
    height: 100%;
    min-height: 300px;
    background: #e5e7eb;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

.map-marker {
    position: absolute;
    transform: translate(-50%, -100%);
    cursor: pointer;
    transition: transform 0.15s ease;
}

.map-marker:hover {
    transform: translate(-50%, -100%) scale(1.1);
}

.map-marker.selected {
    transform: translate(-50%, -100%) scale(1.2);
}

/* ========== Floating Action Button in Sheet ========== */
.sheet-fab {
    position: sticky;
    bottom: 0;
    background: var(--primary);
    color: white;
    padding: 16px 24px;
    border-radius: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 20px rgba(67, 42, 24, 0.3);
    cursor: pointer;
    border: none;
    width: 100%;
    font-size: 16px;
    transition: all 0.15s ease;
}

.sheet-fab:active {
    transform: scale(0.98);
}

.sheet-fab:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========== Search Input ========== */
.search-input-container {
    position: relative;
}

.search-input-container svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: rgba(67, 42, 24, 0.4);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 12px 14px 12px 44px;
    border: 1px solid rgba(67, 42, 24, 0.15);
    border-radius: 12px;
    font-size: 15px;
    background: rgba(67, 42, 24, 0.03);
    transition: all 0.15s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(67, 42, 24, 0.1);
}