/* ============================================
   CLINICALC - Sistema de Diseño v1.0
   Calculadoras Médicas Profesionales
   ============================================ */

/* === VARIABLES CSS === */
:root {
    /* Colores Brand */
    --brand-primary: #1e3872;
    --brand-primary-dark: #13294f;
    --brand-primary-light: #2d4a8c;
    --brand-accent: #78daab;
    --brand-accent-dark: #5bc492;
    --brand-accent-light: #9ae4c1;
    
    /* Colores Semánticos */
    --success: #10b981;
    --success-dark: #059669;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --warning: #f59e0b;
    --warning-light: #fbbf24;
    --info: #3b82f6;
    
    /* Fondos Modo Claro */
    --bg-body: #f8fafc;
    --bg-container: #ffffff;
    --bg-card: #ffffff;
    --bg-secondary: #f1f5f9;
    --bg-tertiary: #e2e8f0;
    --input-bg: #ffffff;
    
    /* Texto Modo Claro */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    
    /* Bordes */
    --border-color: #e2e8f0;
    --border-color-strong: #cbd5e1;
    
    /* Sombras */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    /* Otros */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    
    /* Transiciones */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* === MODO OSCURO === */
body.dark-mode {
    --bg-body: #0f172a;
    --bg-container: #1e293b;
    --bg-card: #1e293b;
    --bg-secondary: #334155;
    --bg-tertiary: #475569;
    --input-bg: #1e293b;
    
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    
    --border-color: #334155;
    --border-color-strong: #475569;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* === SCROLLBAR === */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color-strong);
    border-radius: 4px;
    transition: background var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--brand-primary);
}

/* === SPLASH SCREEN === */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--brand-primary-dark) 0%, var(--brand-primary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeOut 0.5s ease forwards;
    animation-delay: 1.5s;
}

.splash-content {
    text-align: center;
    animation: scaleIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.splash-logo {
    width: 120px;
    height: 120px;
    margin-bottom: 24px;
    animation: float 2s ease-in-out infinite;
}

.splash-title {
    font-size: 32px;
    font-weight: 800;
    color: white;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.splash-subtitle {
    font-size: 16px;
    color: var(--brand-accent-light);
    margin-bottom: 40px;
}

.splash-loader {
    width: 40px;
    height: 40px;
    margin: 0 auto;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--brand-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* === APP CONTAINER === */
.app-container {
    max-width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    opacity: 0;
    animation: fadeIn 0.5s ease forwards;
    animation-delay: 2s;
}

/* === HEADER === */
.app-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    transition: all var(--transition-normal);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-logo {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    transition: transform var(--transition-fast);
}

.app-logo:hover {
    transform: scale(1.05);
}

.app-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.header-right {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.icon-btn:hover {
    background: var(--bg-tertiary);
    transform: scale(1.05);
}

.icon-btn:active {
    transform: scale(0.95);
}

/* === SEARCH BAR === */
.search-container {
    margin-top: 16px;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    animation: slideDown 0.3s ease;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    gap: 12px;
    border: 2px solid transparent;
    transition: all var(--transition-fast);
}

.search-input-wrapper:focus-within {
    border-color: var(--brand-accent);
    background: var(--bg-card);
    box-shadow: 0 0 0 4px rgba(120, 218, 171, 0.1);
}

.search-input-wrapper svg {
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.search-input-wrapper input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 15px;
    color: var(--text-primary);
    outline: none;
    font-family: inherit;
}

.search-input-wrapper input::placeholder {
    color: var(--text-tertiary);
}

.clear-search {
    background: var(--bg-tertiary);
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all var(--transition-fast);
}

.clear-search:hover {
    background: var(--danger);
    color: white;
}

.search-results {
    margin-top: 8px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-height: 400px;
    overflow-y: auto;
    display: none;
}

.search-results.show {
    display: block;
    animation: slideDown 0.2s ease;
}

/* === MAIN CONTENT === */
.app-main {
    flex: 1;
    padding-bottom: 80px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

.content-wrapper {
    padding: 24px 20px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.btn-text {
    background: transparent;
    border: none;
    color: var(--brand-accent);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.btn-text:hover {
    background: rgba(120, 218, 171, 0.1);
}

/* === CATEGORY COLOR TOKENS === */
[data-category="renal"]         { --cat-color: #3b82f6; --cat-color-bg: rgba(59,130,246,0.13); }
[data-category="electrolitos"]  { --cat-color: #06b6d4; --cat-color-bg: rgba(6,182,212,0.13); }
[data-category="antropometria"] { --cat-color: #8b5cf6; --cat-color-bg: rgba(139,92,246,0.13); }
[data-category="cardio"]        { --cat-color: #ef4444; --cat-color-bg: rgba(239,68,68,0.13); }
[data-category="hepato"]        { --cat-color: #f97316; --cat-color-bg: rgba(249,115,22,0.13); }
[data-category="infecciones"]   { --cat-color: #22c55e; --cat-color-bg: rgba(34,197,94,0.13); }
[data-category="neuro"]         { --cat-color: #6366f1; --cat-color-bg: rgba(99,102,241,0.13); }
[data-category="otros"]         { --cat-color: #64748b; --cat-color-bg: rgba(100,116,139,0.13); }
[data-category="critico"]       { --cat-color: #f59e0b; --cat-color-bg: rgba(245,158,11,0.13); }
[data-category="pulmonar"]      { --cat-color: #14b8a6; --cat-color-bg: rgba(20,184,166,0.13); }
[data-category="gastro"]        { --cat-color: #a16207; --cat-color-bg: rgba(161,98,7,0.13); }
[data-category="toxicologia"]   { --cat-color: #d946ef; --cat-color-bg: rgba(217,70,239,0.13); }

/* === CALCULATORS GRID === */
.calculators-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}

.calculator-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px 16px 16px;
    text-align: center;
    cursor: pointer;
    position: relative;
    transition: all var(--transition-normal);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.calculator-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--cat-color, var(--brand-accent));
    opacity: 0.5;
    transition: opacity var(--transition-normal);
}

.calculator-card:hover::before {
    opacity: 1;
}

.calculator-card:hover {
    border-color: var(--cat-color, var(--brand-accent));
    transform: translateY(-4px);
    box-shadow: 0 8px 24px -4px rgba(0,0,0,0.25), 0 0 0 1px var(--cat-color, var(--brand-accent));
}

.calculator-card:active {
    transform: translateY(-2px);
}

/* Icon container */
.calc-icon-wrapper {
    width: 58px;
    height: 58px;
    border-radius: 16px;
    background: var(--cat-color-bg, rgba(120,218,171,0.12));
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    transition: transform var(--transition-normal), background var(--transition-normal);
    flex-shrink: 0;
}

.calculator-card:hover .calc-icon-wrapper {
    transform: scale(1.1) rotate(-4deg);
    background: var(--cat-color-bg, rgba(120,218,171,0.2));
}

.calc-icon {
    font-size: 28px;
    display: block;
    line-height: 1;
}

.calc-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 5px;
    line-height: 1.3;
}

.calc-category {
    font-size: 10px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
}

.cat-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--cat-color, var(--text-tertiary));
    flex-shrink: 0;
    opacity: 0.9;
}

.calc-favorite {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 14px;
    opacity: 0;
    transition: all var(--transition-fast);
    line-height: 1;
}

.calculator-card:hover .calc-favorite,
.calculator-card.favorited .calc-favorite {
    opacity: 1;
}

.calculator-card.favorited .calc-favorite {
    opacity: 1;
}

/* === CATEGORY FILTERS === */
.category-filters {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    margin-bottom: 24px;
    padding-bottom: 8px;
    scrollbar-width: thin;
}

.filter-chip {
    background: var(--bg-secondary);
    border: 2px solid transparent;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.filter-chip:hover {
    background: var(--bg-tertiary);
}

.filter-chip.active {
    background: var(--brand-accent);
    color: var(--brand-primary-dark);
    border-color: var(--brand-accent-dark);
}

/* === CALCULATORS LIST === */
.calculators-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.calculator-list-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.calculator-list-item:hover {
    border-color: var(--cat-color, var(--brand-accent));
    transform: translateX(4px);
}

.calc-list-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: var(--cat-color-bg, rgba(120,218,171,0.1));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
    transition: transform var(--transition-fast);
}

.calculator-list-item:hover .calc-list-icon {
    transform: scale(1.08);
}

.calc-list-info {
    flex: 1;
}

.calc-list-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.calc-list-description {
    font-size: 13px;
    color: var(--text-secondary);
}

.calc-list-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.calc-list-favorite {
    font-size: 20px;
    flex-shrink: 0;
    opacity: 0.3;
    transition: all var(--transition-fast);
}

.calculator-list-item.favorited .calc-list-favorite {
    opacity: 1;
}

.calc-list-mainscreen {
    font-size: 19px;
    flex-shrink: 0;
    opacity: 0.3;
    filter: grayscale(1);
    transition: all var(--transition-fast);
}

.calculator-list-item.on-mainscreen .calc-list-mainscreen {
    opacity: 1;
    filter: none;
}

/* === SETTINGS === */
.settings-section {
    margin-bottom: 32px;
}

.settings-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-description {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.5;
}

.setting-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    transition: all var(--transition-fast);
}

.setting-info {
    flex: 1;
}

.setting-label {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.setting-description {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 0;
}

.setting-select {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 200px;
    max-width: 280px;
}

.setting-select:focus {
    outline: none;
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 4px rgba(120, 218, 171, 0.1);
}

/* === TOGGLE SWITCH === */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-tertiary);
    border-radius: 28px;
    transition: var(--transition-normal);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: var(--transition-normal);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .toggle-slider {
    background: var(--brand-accent);
}

input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

/* === CALC COUNTER === */
.calc-counter {
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: var(--radius-lg);
    text-align: center;
    margin-bottom: 20px;
}

.counter-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-right: 8px;
}

.counter-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--brand-accent);
}

.counter-total {
    font-size: 16px;
    color: var(--text-tertiary);
}

/* === MANAGE CALCULATORS LIST === */
.calculators-manage-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.calc-manage-item {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.calc-manage-item:hover {
    border-color: var(--brand-accent);
}

.calc-manage-item.active {
    background: rgba(120, 218, 171, 0.1);
    border-color: var(--brand-accent);
}

.calc-checkbox {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 2px solid var(--border-color-strong);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.calc-manage-item.active .calc-checkbox {
    background: var(--brand-accent);
    border-color: var(--brand-accent);
}

.calc-checkbox svg {
    display: none;
    width: 14px;
    height: 14px;
    stroke: var(--brand-primary-dark);
    stroke-width: 3;
}

.calc-manage-item.active .calc-checkbox svg {
    display: block;
}

/* === BUTTONS === */
.btn {
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition-fast);
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand-accent-dark), var(--brand-accent));
    color: var(--brand-primary-dark);
    box-shadow: 0 4px 12px rgba(120, 218, 171, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 16px rgba(120, 218, 171, 0.4);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
}

.btn-danger-outline {
    background: transparent;
    color: var(--danger);
    border: 2px solid var(--danger);
}

.btn-danger-outline:hover {
    background: var(--danger);
    color: white;
}

.settings-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.settings-actions .btn {
    flex: 1;
    min-width: 140px;
}

/* === INFO GRID === */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.info-item {
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: var(--radius-md);
    text-align: center;
}

.info-label {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 6px;
}

.info-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

/* === EMPTY STATE === */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon {
    font-size: 80px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* === BOTTOM NAV === */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    z-index: 100;
    backdrop-filter: blur(10px);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.nav-item span {
    font-size: 11px;
    font-weight: 600;
}

.nav-item.active {
    color: var(--brand-accent);
}

.nav-item svg {
    stroke-width: 2;
    transition: all var(--transition-fast);
}

.nav-item.active svg {
    stroke-width: 2.5;
}

/* === TOAST NOTIFICATIONS === */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background: var(--bg-card);
    border-left: 4px solid var(--brand-accent);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    min-width: 280px;
    max-width: 400px;
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInRight 0.3s ease;
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.warning {
    border-left-color: var(--warning);
}

.toast-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.toast-message {
    font-size: 13px;
    color: var(--text-secondary);
}

/* === ANIMATIONS === */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes slideDown {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes slideInRight {
    from { transform: translateX(100px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .calculators-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }
    
    .calculator-card {
        padding: 16px 10px 14px;
    }

    .calc-icon-wrapper {
        width: 50px;
        height: 50px;
        border-radius: 14px;
    }

    .calc-icon {
        font-size: 24px;
    }
    
    .settings-actions {
        flex-direction: column;
    }
    
    .settings-actions .btn {
        width: 100%;
    }
    
    .toast-container {
        right: 12px;
        left: 12px;
    }
    
    .toast {
        min-width: 0;
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .app-title {
        font-size: 18px;
    }

    .app-logo {
        width: 32px;
        height: 32px;
    }

    .calculators-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

/* === UPDATE BANNER === */
@keyframes bannerSlideUp {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
@keyframes bannerSlideDown {
    from { transform: translateY(0);    opacity: 1; }
    to   { transform: translateY(100%); opacity: 0; }
}

.update-banner {
    position: fixed;
    bottom: 76px; /* encima del nav bar */
    left: 12px;
    right: 12px;
    background: var(--bg-card);
    border: 1px solid var(--brand-accent);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-xl), 0 0 0 1px rgba(120,218,171,0.15);
    z-index: 9999;
    animation: bannerSlideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 600px;
    margin: 0 auto;
}

.update-banner--dismissing {
    animation: bannerSlideDown 0.3s ease forwards;
}

.update-banner__icon {
    font-size: 22px;
    flex-shrink: 0;
    width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.update-banner__body {
    flex: 1;
    min-width: 0;
}

.update-banner__title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.update-banner__sub {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.update-banner__actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.update-btn {
    border: none;
    border-radius: var(--radius-sm);
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--transition-fast);
}

.update-btn--primary {
    background: var(--brand-accent);
    color: var(--brand-primary-dark);
}

.update-btn--primary:hover {
    background: var(--brand-accent-light);
    transform: translateY(-1px);
}

.update-btn--secondary {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

.update-btn--secondary:hover {
    background: var(--bg-tertiary);
}

.update-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--brand-accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* === REORDER MODAL (Bottom Sheet) === */
.reorder-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.reorder-modal {
    background: var(--bg-card);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.reorder-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.reorder-modal-header h3 {
    font-size: 17px;
    font-weight: 700;
}

.reorder-hint {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 16px;
}

.reorder-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    user-select: none;
    transition: box-shadow 0.15s ease;
}

.reorder-handle {
    font-size: 20px;
    color: var(--text-tertiary);
    cursor: grab;
    touch-action: none;
    padding: 2px 4px;
    line-height: 1;
    flex-shrink: 0;
}

.reorder-handle:active { cursor: grabbing; }

.reorder-icon {
    font-size: 22px;
    flex-shrink: 0;
}

.reorder-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.reorder-item-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 10001;
    opacity: 0.93;
    border: 1px solid var(--brand-accent);
    box-shadow: 0 16px 40px rgba(0,0,0,0.4);
    transform: scale(1.03);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
}

.reorder-item-placeholder {
    background: rgba(120, 218, 171, 0.07);
    border: 2px dashed var(--brand-accent);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    opacity: 0.6;
}
