:root {
    --bg-color: #040d21;
    --surface-color: rgba(13, 22, 43, 0.65);
    --surface-hover: rgba(20, 33, 61, 0.85);
    --primary: #f97316; /* Naranja Vibrante */
    --primary-hover: #ea580c;
    --secondary: #2563eb; /* Azul Vibrante */
    --text-main: #ffffff;
    --text-muted: #cbd5e1;
    --border: rgba(249, 115, 22, 0.25); /* Borde con toque naranja */
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    --danger: #ef4444;
    --success: #10b981;
    --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Outfit', sans-serif; -webkit-tap-highlight-color: transparent; }

html { height: 100%; }

body {
    color: var(--text-main);
    min-height: 100%;
    overflow-x: hidden;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -2;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(circle at 10% 0%, rgba(255, 106, 0, 0.45) 0%, transparent 40%),
        radial-gradient(circle at 90% 10%, rgba(0, 119, 255, 0.55) 0%, transparent 45%),
        radial-gradient(circle at 50% 90%, rgba(255, 123, 0, 0.35) 0%, transparent 50%),
        radial-gradient(circle at 0% 100%, rgba(0, 85, 255, 0.45) 0%, transparent 50%);
    pointer-events: none;
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background: radial-gradient(circle at 50% 50%, rgba(255, 106, 0, 0.15) 0%, transparent 60%);
    animation: pulseGlow 8s ease-in-out infinite alternate;
    pointer-events: none;
}

@keyframes pulseGlow {
    0% { opacity: 0.4; }
    100% { opacity: 0.8; }
}

.hidden { display: none !important; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.w-full { width: 100%; }

/* ===== LAYOUT ===== */
.app-container { display: flex; min-height: 100vh; min-height: 100dvh; }

/* ===== SIDEBAR ===== */
.sidebar {
    width: 260px;
    min-width: 260px;
    background: rgba(13, 20, 38, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(.4,0,.2,1);
    z-index: 1100;
    flex-shrink: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem 1.2rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.5rem;
}

.sidebar-close {
    display: none;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    transition: all 0.2s;
}
.sidebar-close:hover { background: var(--danger); color: white; }

.logo { font-size: 1.4rem; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 0.5rem; }

.nav-links { list-style: none; padding: 0.5rem 0; }

.nav-links li {
    padding: 0.85rem 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    color: var(--text-muted);
    border-left: 3px solid transparent;
    font-size: 0.95rem;
    font-weight: 500;
    user-select: none;
}
.nav-links li:hover, .nav-links li.active { background: rgba(59,130,246,0.12); color: var(--text-main); border-left-color: var(--primary); }
.nav-links li.active { color: var(--primary); font-weight: 600; }
.nav-links li i { width: 20px; text-align: center; }

/* ===== OVERLAY ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 1050;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

/* ===== TOPBAR ===== */
.topbar {
    display: none;
    align-items: center;
    gap: 0.8rem;
    padding: 0 0 0.8rem 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.hamburger {
    background: var(--surface-color);
    border: 1px solid var(--border);
    color: var(--text-main);
    font-size: 1.2rem;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}
.hamburger:hover, .hamburger:active { background: var(--primary); }

.topbar-title { font-weight: 700; font-size: 1.15rem; color: var(--primary); }

/* ===== CONTENT ===== */
.content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.view { display: none; animation: fadeIn 0.3s ease-out forwards; }
.view.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

header { margin-bottom: 1.5rem; }
header h1 { font-size: 1.7rem; font-weight: 700; margin-bottom: 0.25rem; }
header p { color: var(--text-muted); font-size: 0.9rem; }

.badge { background: var(--primary); padding: 0.2rem 0.6rem; border-radius: 4px; font-size: 0.85rem; }

/* ===== DASHBOARD ===== */
.dashboard-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1.2rem; }

.card {
    background: var(--surface-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.8rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    user-select: none;
}
.card:hover, .card:active { transform: translateY(-4px); background: var(--surface-hover); box-shadow: var(--glass-shadow); }
.card i { font-size: 2.2rem; color: var(--primary); margin-bottom: 0.8rem; display: block; }
.card h3 { font-size: 0.95rem; font-weight: 600; }

/* ===== FORMS ===== */
.glass-form {
    background: var(--surface-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.8rem; margin-bottom: 0.8rem; }
.form-group { display: flex; flex-direction: column; margin-bottom: 0.75rem; }
.form-group label { margin-bottom: 0.35rem; font-weight: 500; color: var(--text-muted); font-size: 0.85rem; }

input:not([type="checkbox"]), select, textarea {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.65rem 0.9rem;
    color: var(--text-main);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    font-size: 16px;
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    font-family: 'Outfit', sans-serif;
}
input[type="checkbox"] {
    -webkit-appearance: checkbox !important;
    appearance: checkbox !important;
    width: 1.2rem !important;
    height: 1.2rem !important;
    flex-shrink: 0 !important;
    cursor: pointer;
    accent-color: var(--primary);
}
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 2.2rem;
}
select option { background: #1e293b; color: var(--text-main); }
input:not([type="checkbox"]):focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
input[readonly] { opacity: 0.7; }
textarea { resize: vertical; min-height: 75px; }

/* ===== BUTTONS ===== */
button {
    cursor: pointer;
    font-weight: 600;
    border-radius: 8px;
    padding: 0.7rem 1.1rem;
    border: none;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    font-size: 0.9rem;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
    font-family: 'Outfit', sans-serif;
}
button:active { transform: scale(0.97); }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover, .btn-primary:active { background: var(--primary-hover); }
.btn-secondary { background: rgba(100,116,139,0.5); color: white; border: 1px solid var(--border); }
.btn-secondary:hover, .btn-secondary:active { background: var(--secondary); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover, .btn-danger:active { background: #dc2626; }

.section-title { margin: 1.2rem 0 0.8rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); color: var(--primary); font-size: 0.95rem; font-weight: 600; }

/* ===== COLLAPSIBLE PANELS ===== */
.section-title.collapsible {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    padding: 0.75rem 0;
    transition: color 0.2s;
    margin-top: 0.3rem;
}
.section-title.collapsible:hover { color: var(--primary-hover); }
.panel-arrow { transition: transform 0.3s ease; font-size: 0.75rem; margin-left: auto; flex-shrink: 0; }
.section-title.collapsed .panel-arrow { transform: rotate(180deg); }
.panel-body { overflow: hidden; max-height: 3000px; transition: max-height 0.4s ease, opacity 0.3s ease; opacity: 1; padding-bottom: 0.3rem; }
.panel-body.collapsed { max-height: 0; opacity: 0; overflow: hidden; padding-bottom: 0; }

/* ===== FOLDER GRID ===== */
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; }

.folder-item {
    background: var(--surface-color);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    user-select: none;
}
.folder-item:hover, .folder-item:active { background: var(--primary); transform: scale(1.02); }
.folder-item i { font-size: 1.8rem; margin-bottom: 0.4rem; display: block; }
.folder-item h3 { font-size: 0.9rem; font-weight: 600; }
.folder-category-badge { display: block; font-size: 0.78rem; color: var(--text-muted); margin-top: 0.3rem; }
.folder-item:hover .folder-category-badge { color: #e2e8f0; }

/* ===== LOCATION ===== */
.location-controls { display: flex; gap: 0.8rem; margin-bottom: 1rem; flex-wrap: wrap; }
.location-controls button { flex: 1; min-width: 140px; }

/* ===== MAP ===== */
.map-wrapper-tall {
    height: 380px;
    border-radius: var(--radius);
    overflow: hidden;
    margin-top: 0.8rem;
    position: relative;
    border: 1px solid var(--border);
}
#map, #global-map { height: 100%; width: 100%; z-index: 1; }

.map-search {
    position: absolute;
    top: 10px;
    left: 50px;
    right: 10px;
    z-index: 1000;
    display: flex;
    gap: 0.5rem;
}
.map-search input { background: white; color: #1e293b; border: none; flex: 1; box-shadow: 0 2px 8px rgba(0,0,0,0.25); }
.map-search button { background: var(--primary); padding: 0.65rem; color: white; border-radius: 8px; }

/* ===== PHOTOS ===== */
.photos-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.8rem; }
.photo-box label { display: block; margin-bottom: 0.35rem; font-size: 0.82rem; color: var(--text-muted); font-weight: 500; }

.photo-placeholder {
    width: 100%;
    aspect-ratio: 1;
    background: rgba(15, 23, 42, 0.5);
    border: 2px dashed rgba(255,255,255,0.15);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    overflow: hidden;
    position: relative;
}
.photo-placeholder:hover, .photo-placeholder:active { border-color: var(--primary); background: rgba(59,130,246,0.12); }
.photo-placeholder i { font-size: 1.6rem; color: var(--text-muted); }
.photo-placeholder img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: rgba(15, 23, 42, 0.8); }

/* ===== MODALS ===== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.82);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-content {
    background: #1a2540;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 100%;
    max-width: 800px;
    position: relative;
    margin: auto;
}
.modal-content h2 { font-size: 1.2rem; margin-bottom: 1rem; color: var(--primary); }

.img-container-crop { max-height: 45vh; margin: 1rem 0; overflow: hidden; border-radius: 8px; }
.img-container-crop img { max-width: 100%; display: block; }

.modal-actions { display: flex; justify-content: flex-end; gap: 0.7rem; margin-top: 1.2rem; flex-wrap: wrap; }

/* ===== PREVIEW ===== */
.preview-grid { display: flex; flex-direction: column; gap: 0.7rem; }
.preview-item { background: rgba(15,23,42,0.6); padding: 0.75rem 1rem; border-radius: 8px; }
.preview-item strong { color: var(--primary); display: block; margin-bottom: 0.2rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.preview-photos { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.5rem; }
.preview-photos img { width: 80px; height: 80px; object-fit: contain; background: rgba(15, 23, 42, 0.8); border-radius: 8px; border: 1px solid var(--border); }

/* ===== HISTORY ===== */
.history-grid { display: flex; flex-direction: column; gap: 0.8rem; }

.history-card {
    background: var(--surface-color);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.8rem;
    transition: background 0.2s;
}
.history-card:hover { background: var(--surface-hover); }

.history-info { flex: 1; min-width: 0; }
.history-info h3 { color: var(--primary); margin-bottom: 0.25rem; font-size: 1rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-info p { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 0.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.history-actions { display: flex; gap: 0.4rem; align-items: center; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.history-actions button { padding: 0.5rem 0.6rem; font-size: 0.82rem; }

.filters { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.filters .form-group { margin-bottom: 0; }

/* ===== LEAFLET OVERRIDES ===== */
.leaflet-container { font-family: 'Outfit', sans-serif !important; }
.leaflet-control-attribution { font-size: 9px !important; }
.leaflet-popup-content-wrapper { background: #1e293b !important; color: var(--text-main) !important; border: 1px solid var(--border); border-radius: 8px !important; box-shadow: var(--glass-shadow) !important; }
.leaflet-popup-tip { background: #1e293b !important; }
.leaflet-popup-content strong { color: var(--primary); }
.leaflet-control-zoom a { background: #1e293b !important; color: var(--text-main) !important; border-color: var(--border) !important; }
.leaflet-control-zoom a:hover { background: var(--primary) !important; color: white !important; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        height: 100dvh;
        transform: translateX(-100%);
        will-change: transform;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .sidebar-close { display: flex; }
    .topbar { display: flex; }

    .content { padding: 0.9rem 1rem 1.2rem; }
    header h1 { font-size: 1.3rem; }
    header { margin-bottom: 1rem; }

    .map-wrapper-tall { height: 300px; }
    .dashboard-cards { grid-template-columns: repeat(2, 1fr); gap: 0.8rem; }
    .card { padding: 1.4rem 1rem; }
    .card i { font-size: 1.9rem; }
    .form-grid { grid-template-columns: 1fr; }
    .glass-form { padding: 1.1rem; }
    .photos-grid { grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
    .history-card { flex-direction: column; }
    .history-card .history-info h3, .history-card .history-info p { white-space: normal; }
    .history-actions { width: 100%; justify-content: flex-end; }
    .modal-content { padding: 1.1rem; }
    .preview-photos img { width: 70px; height: 70px; }
}

@media (max-width: 480px) {
    .dashboard-cards { grid-template-columns: repeat(2, 1fr); }
    .photos-grid { grid-template-columns: repeat(2, 1fr); }
    .location-controls { flex-direction: column; }
    .location-controls button { width: 100%; }
    .history-actions button { flex: 1 0 auto; }
    .modal-actions { flex-direction: column-reverse; }
    .modal-actions button { width: 100%; justify-content: center; }
    .map-wrapper-tall { height: 260px; }
}

/* ===== AUTHENTICATION ===== */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1.5rem;
    position: relative;
    z-index: 10;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 2.5rem 2rem;
    box-shadow: var(--glass-shadow);
    border: 1px solid var(--border);
    animation: fadeIn 0.4s ease-out forwards;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    text-shadow: 0 0 15px rgba(249, 115, 22, 0.3);
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-top: 0.4rem;
    font-weight: 500;
}

.auth-tabs {
    display: flex;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.25rem;
    margin-bottom: 1.8rem;
}

.auth-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.6rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.auth-tab:hover {
    color: var(--text-main);
}

.auth-tab.active {
    background: var(--primary);
    color: white;
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon input {
    padding-left: 2.6rem !important;
}

.input-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
    font-size: 0.95rem;
    pointer-events: none;
}

.toggle-password-icon {
    position: absolute;
    right: 1rem;
    color: var(--text-muted);
    font-size: 0.95rem;
    cursor: pointer;
    transition: color 0.2s;
    padding: 0.5rem;
}

.toggle-password-icon:hover {
    color: var(--primary);
}

.checkbox-group {
    margin: 1.2rem 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    font-size: 0.88rem;
    color: var(--text-muted);
    user-select: none;
}

.checkbox-label a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.checkbox-label a:hover {
    text-decoration: underline;
}

.btn-auth {
    padding: 0.85rem !important;
    font-size: 1rem !important;
    margin-top: 0.5rem;
}

.auth-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    margin-top: 1rem;
    color: var(--text-muted);
    font-size: 0.88rem;
}
