/* ============================================================
   KIPET WEBAPP — DESIGN SYSTEM
   Color primario: #0babb7 | Secundario: #e2dd14
   ============================================================ */

/* ===================== VARIABLES ===================== */
:root {
    --primary: #0babb7;
    --primary-light: #14c8d5;
    --primary-dark: #099da8;
    --primary-glow: rgba(11, 171, 183, 0.2);
    --secondary: #e2dd14;
    --secondary-light: #ede94a;

    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-alt: #f8f9fb;
    --text: #1a1a2e;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border: #e8eaed;
    --input-bg: #f3f4f6;
    --danger: #ef4444;
    --success: #22c55e;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.1);
    --shadow-xl: 0 12px 40px rgba(0,0,0,0.12);

    --nav-bg: rgba(26, 26, 46, 0.92);
    --nav-text: #ffffff;
    --modal-overlay: rgba(0,0,0,0.45);

    --radius-xs: 8px;
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-pill: 50px;
    --radius-full: 50%;

    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===================== DARK MODE ===================== */
[data-theme="dark"] {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-alt: #1c2129;
    --text: #f0f6fc;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --border: #30363d;
    --input-bg: #0d1117;
    --nav-bg: rgba(13, 17, 23, 0.94);
    --modal-overlay: rgba(0,0,0,0.65);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.15);
    --shadow: 0 2px 8px rgba(0,0,0,0.2);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.3);
    --shadow-xl: 0 12px 40px rgba(0,0,0,0.4);
}

/* ===================== RESET & BASE ===================== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
}
body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100%;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
input, button, textarea, select { font-family: inherit; }

#app {
    min-height: 100vh;
}

/* ===================== LOADING SCREEN ===================== */
.loading-screen {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
}
.loading-logo {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-md);
    animation: pulse-logo 1.8s ease-in-out infinite;
}
.loading-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse-logo {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.96); }
}

/* ===================== AUTH PAGE ===================== */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(160deg, var(--bg) 0%, var(--surface) 100%);
}
.auth-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 36px 28px 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-xl);
    text-align: center;
    border: 1px solid var(--border);
}
.auth-logo {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-md);
    margin: 0 auto 16px;
    box-shadow: var(--shadow);
}
.auth-title {
    font-size: 26px;
    font-weight: 800;
    color: var(--primary);
    margin: 0 0 2px;
}
.auth-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0 0 28px;
    font-weight: 400;
}

/* Auth Tabs */
.auth-tabs {
    display: flex;
    background: var(--input-bg);
    border-radius: var(--radius-pill);
    padding: 4px;
    margin-bottom: 24px;
}
.auth-tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    border-radius: var(--radius-pill);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}
.auth-tab.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* Auth Form */
.auth-form { text-align: left; }
.auth-hint {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    text-align: center;
    line-height: 1.5;
}
.auth-error {
    font-size: 12px;
    color: var(--danger);
    margin-top: 10px;
    min-height: 16px;
    text-align: center;
}
.phone-row {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}
.phone-select {
    width: 110px;
    padding: 14px 8px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    background: var(--input-bg);
    color: var(--text);
    appearance: none;
    text-align: center;
    cursor: pointer;
}
.phone-input { flex: 1; }

.otp-input {
    font-size: 26px !important;
    text-align: center;
    letter-spacing: 8px;
    font-weight: 700;
}

/* ===================== HEADER ===================== */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(12px);
}
.header-logo {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    box-shadow: var(--shadow-sm);
}
.header-avatar {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: -0.5px;
}

/* ===================== BOTTOM NAV ===================== */
.bottom-nav-wrapper {
    position: fixed;
    bottom: 24px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    z-index: 90;
    pointer-events: none;
}
.bottom-nav {
    background: var(--nav-bg);
    backdrop-filter: blur(16px);
    border-radius: 28px;
    padding: 6px 20px;
    display: flex;
    gap: 8px;
    pointer-events: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.06);
}
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 10px;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    gap: 2px;
}
.nav-item.active {
    color: #fff;
    background: rgba(255,255,255,0.1);
}
.nav-item .nav-icon {
    width: 22px;
    height: 22px;
}

/* ===================== MAIN CONTENT ===================== */
.app-main {
    padding-bottom: 100px;
}
.page-content {
    padding: 20px;
    max-width: 500px;
    margin: 0 auto;
}

/* ===================== GREETING ===================== */
.greeting-section {
    margin-bottom: 24px;
}
.greeting-title {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    line-height: 1.3;
}
.greeting-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ===================== SECTION ===================== */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.section-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-secondary);
}
.page-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}
.page-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* ===================== TAG CARDS ===================== */
.tags-container { display: flex; flex-direction: column; gap: 12px; }

.tag-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    border: 1px solid var(--border);
}
.tag-card:active { transform: scale(0.98); }

.tag-photo, .tag-photo-placeholder {
    width: 54px;
    height: 54px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
}
.tag-photo-placeholder {
    background: var(--primary-glow);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
}
.tag-info { flex: 1; min-width: 0; }
.tag-name {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tag-code {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}
.tag-action {
    color: var(--text-muted);
    flex-shrink: 0;
    opacity: 0.6;
}

/* ===================== ACTIVATE BUTTON ===================== */
.btn-activate {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    margin-top: 20px;
    background: transparent;
    border: 2px dashed var(--primary);
    border-radius: var(--radius-md);
    color: var(--primary);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.btn-activate:hover {
    background: var(--primary-glow);
}

/* ===================== BUTTONS ===================== */
.form-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    background: var(--input-bg);
    color: var(--text);
    outline: none;
    transition: border-color var(--transition);
    margin-bottom: 12px;
}
.form-input:focus { border-color: var(--primary); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.btn-primary {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius-pill);
    background: var(--primary);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 14px var(--primary-glow);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius-pill);
    background: var(--input-bg);
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: block;
    text-align: center;
}

.btn-danger {
    width: 100%;
    padding: 14px;
    border: 2px solid var(--danger);
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--danger);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 16px;
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-link {
    display: block;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    padding: 10px;
    text-align: center;
    width: 100%;
    margin-top: 4px;
}

.btn-edit {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: var(--radius-xs);
    transition: var(--transition);
}
.btn-edit:hover { background: var(--input-bg); }

/* ===================== EMPTY STATE ===================== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}
.empty-state h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.empty-state p {
    font-size: 13px;
    line-height: 1.5;
    max-width: 260px;
    margin: 0 auto;
}

/* ===================== SCAN HISTORY ===================== */
.history-container { display: flex; flex-direction: column; gap: 10px; }

.scan-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    display: flex;
    gap: 14px;
    align-items: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}
.scan-icon {
    font-size: 24px;
    flex-shrink: 0;
}
.scan-info { flex: 1; min-width: 0; }
.scan-info h4 {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 4px;
}
.scan-code {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 12px;
}
.scan-date {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
}
.scan-location {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}
.scan-no-gps {
    color: var(--text-muted);
    font-style: italic;
    font-size: 11px;
}
.scan-ip {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
    opacity: 0.7;
}
.btn-maps {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    background: var(--primary);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-pill);
    text-decoration: none;
    transition: var(--transition);
    box-shadow: 0 2px 8px var(--primary-glow);
    flex-shrink: 0;
}
.btn-maps:hover {
    background: var(--primary-dark);
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
    padding: 8px 0;
}
.pag-btn {
    padding: 10px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.pag-btn:hover:not(:disabled) {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.pag-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.pag-info {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ===================== HELP ===================== */
.help-section { display: flex; flex-direction: column; gap: 12px; }

.help-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}
.help-icon {
    font-size: 28px;
    margin-bottom: 10px;
}
.help-card h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
}
.help-card p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}
.help-contact {
    text-align: center;
    margin-top: 32px;
}
.help-contact p {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* ===================== ACCOUNT ===================== */
.account-header {
    text-align: center;
    margin-bottom: 28px;
}
.account-avatar {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-lg);
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 700;
    margin: 0 auto 12px;
    box-shadow: 0 4px 14px var(--primary-glow);
}
.account-name {
    font-size: 20px;
    font-weight: 700;
}
.account-actions {
    margin-top: 28px;
}

/* Profile Card */
.profile-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}
.profile-field {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}
.profile-field:last-child { border-bottom: none; }
.profile-field label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.field-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 2px;
}
.field-value {
    font-size: 15px;
    font-weight: 500;
}

/* Theme Toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    user-select: none;
}
.toggle-switch {
    width: 48px;
    height: 28px;
    background: var(--border);
    border-radius: 14px;
    position: relative;
    transition: var(--transition);
}
.toggle-switch.active { background: var(--primary); }
.toggle-knob {
    width: 22px;
    height: 22px;
    background: #fff;
    border-radius: 50%;
    position: absolute;
    top: 3px;
    left: 3px;
    transition: var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle-switch.active .toggle-knob { left: 23px; }

/* ===================== MODAL ===================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--modal-overlay);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}
.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}
.modal-sheet {
    background: var(--surface);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 8px 24px 32px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}
.modal-overlay.active .modal-sheet {
    transform: translateY(0);
}
.modal-handle {
    width: 36px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 8px auto 20px;
}
.modal-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
    text-align: center;
}
.modal-text {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 18px;
    text-align: center;
    line-height: 1.5;
}
.modal-error {
    font-size: 12px;
    color: var(--danger);
    margin-top: 8px;
    min-height: 16px;
    text-align: center;
}
.modal-close-btn { margin-top: 8px; }

.success-badge {
    font-size: 40px;
    text-align: center;
    margin-bottom: 8px;
}

/* Edit Photo in Modal */
.edit-photo-container {
    width: 90px;
    height: 90px;
    border-radius: var(--radius-full);
    margin: 0 auto 20px;
    position: relative;
    cursor: pointer;
    overflow: hidden;
}
.edit-photo-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-full);
}
.edit-photo-placeholder {
    width: 100%;
    height: 100%;
    background: var(--primary-glow);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    border-radius: var(--radius-full);
}
.edit-photo-badge {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 28px;
    height: 28px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    border: 2px solid var(--surface);
}

/* ===================== SKELETON ===================== */
.skeleton-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    height: 80px;
    margin-bottom: 12px;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
}
.skeleton-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, var(--input-bg), transparent);
    animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ===================== TOAST ===================== */
.app-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-80px);
    background: var(--text);
    color: var(--bg);
    padding: 12px 24px;
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}
.app-toast.show { transform: translateX(-50%) translateY(0); }

/* ===================== PAGE TRANSITION ===================== */
.page-content {
    animation: fadeUp 0.3s ease;
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 380px) {
    .bottom-nav { gap: 4px; padding: 6px 14px; }
    .nav-item { padding: 8px 10px; }
    .page-content { padding: 16px; }
}

/* iOS safe area */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .bottom-nav-wrapper {
        bottom: calc(16px + env(safe-area-inset-bottom));
    }
}
