/* --- VARIABLES & TEMA --- */
:root {
    color-scheme: dark;
    --bg-color: #1c1c1e;
    --text-color: #ffffff;
    --text-secondary: #8e8e93;
    --accent-color: #007AFF;
    --glass-bg: rgba(44, 44, 46, 0.75);
    --glass-border: rgba(255, 255, 255, 0.12);
    --input-bg: rgba(0, 0, 0, 0.25);
    --danger-color: #ff453a;
    --success-color: #32d74b;
    --card-bg: #252527;
    --nav-height: 65px;
    --header-height: 75px;
}

@media (prefers-color-scheme: light) {
    :root {
        color-scheme: light;
        --bg-color: #f2f2f7;
        --text-color: #000000;
        --text-secondary: #3c3c4399;
        --glass-bg: rgba(255, 255, 255, 0.85);
        --glass-border: rgba(60, 60, 67, 0.18);
        --input-bg: rgba(118, 118, 128, 0.12);
        --card-bg: #ffffff;
    }
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, sans-serif; }

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    padding-top: calc(var(--header-height) + 15px);
    padding-bottom: calc(var(--nav-height) + 20px);
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

/* --- UTILIDADES --- */
.hidden { display: none !important; }
.centered-title { text-align: center; width: 100%; font-size: 1.1rem; font-weight: 600; margin: 0; line-height: 1.2; }

/* --- GLASS HEADER & BADGE --- */
.glass-header {
    background: var(--glass-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-bottom: 0.5px solid var(--glass-border);
    position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
    height: var(--header-height);
    display: flex; align-items: center; justify-content: center;
    padding: 0 15px;
}
.header-content { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; }
.glass-header .icon-btn { position: absolute; right: 15px; top: 50%; transform: translateY(-50%); }

.header-badge {
    background-color: var(--accent-color);
    color: white; font-size: 11px; font-weight: 600;
    padding: 2px 10px; border-radius: 12px; margin-top: 4px;
    box-shadow: 0 2px 6px rgba(0, 122, 255, 0.3);
}

.glass-panel { background: var(--glass-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid var(--glass-border); border-radius: 18px; padding: 20px; box-shadow: 0 4px 24px rgba(0,0,0,0.1); }

/* --- INPUTS --- */
.glass-input { width: 100%; display: block; appearance: none; background: var(--input-bg); border: 1px solid var(--glass-border); border-radius: 12px; padding: 14px; color: var(--text-color); font-size: 16px; margin-bottom: 16px; outline: none; transition: border-color 0.2s, background 0.2s; }
.glass-input:focus { border-color: var(--accent-color); }
.glass-input.big-input { font-size: 18px; font-weight: 600; text-align: center; }
.input-label { display: block; margin-bottom: 4px; font-size: 0.8rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 10px; }

/* --- API SEARCH BOX --- */
.api-search-container { display: flex; align-items: stretch; margin-bottom: 5px; }
.btn-api-search {
    background: var(--accent-color); color: white; border: none;
    border-radius: 0 12px 12px 0; padding: 0 15px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.btn-api-search:active { opacity: 0.8; }

/* --- BUTTONS --- */
.btn-primary { width: 100%; background: var(--accent-color); color: white; border: none; padding: 16px; border-radius: 12px; font-size: 17px; font-weight: 600; cursor: pointer; box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3); margin-bottom: 10px; }
.btn-secondary { display: block; width: 100%; background: var(--input-bg); color: var(--text-color); padding: 14px; border-radius: 12px; text-align: center; cursor: pointer; border: none; font-size: 16px; }
.btn-text { background: none; border: none; color: var(--danger-color); font-size: 15px; margin-top: 5px; cursor: pointer; width: 100%; }
.icon-btn { background: none; border: none; color: var(--accent-color); padding: 5px; cursor: pointer; }

/* --- SEARCH --- */
.relative-wrapper { position: relative; width: 100%; margin-bottom: 10px; }
.search-icon-left { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-secondary); pointer-events: none; }
.search-input-padded { padding-left: 38px !important; padding-right: 38px !important; margin-bottom: 0 !important; }
.btn-clear { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--text-secondary); padding: 8px; cursor: pointer; display: flex; align-items: center; }

/* --- FILTROS --- */
.filter-scroll { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 15px; scrollbar-width: none; -ms-overflow-style: none; }
.filter-scroll::-webkit-scrollbar { display: none; }
.filter-chip { background: var(--input-bg); color: var(--text-secondary); border: 1px solid var(--glass-border); border-radius: 20px; padding: 8px 16px; font-size: 14px; white-space: nowrap; cursor: pointer; transition: all 0.2s; }
.filter-chip.active { background: var(--accent-color); color: white; border-color: var(--accent-color); font-weight: 500; }

/* --- VISTAS --- */
.view-section { display: none; padding: 15px; opacity: 0; transition: opacity 0.2s ease-in; }
.view-section.active { display: block; opacity: 1; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* --- BOOK CARDS --- */
.book-card-container { margin-bottom: 16px; position: relative; border-radius: 16px; overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,0.05); }

/* Swipe Backgrounds */
.swipe-bg-delete { 
    position: absolute; top: 0; bottom: 0; right: 0; width: 100%; 
    background: var(--danger-color); 
    display: flex; align-items: center; justify-content: flex-end; 
    padding-right: 25px; font-weight: bold; font-size: 14px; color: white;
    z-index: 1; opacity: 0; transition: opacity 0.2s;
}
.swipe-bg-edit { 
    position: absolute; top: 0; bottom: 0; left: 0; width: 100%; 
    background: var(--accent-color); 
    display: flex; align-items: center; justify-content: flex-start; 
    padding-left: 25px; font-weight: bold; font-size: 14px; color: white;
    z-index: 1; opacity: 0; transition: opacity 0.2s;
}

.book-card { background: var(--card-bg); padding: 18px; border-radius: 16px; position: relative; z-index: 2; transition: transform 0.1s linear; border: 1px solid var(--glass-border); }

.book-header { display: flex; justify-content: space-between; align-items: flex-start; }
.book-title { font-size: 17px; font-weight: 600; color: var(--text-color); margin-bottom: 4px; }
.book-author { color: var(--text-secondary); font-size: 14px; }
.book-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge { font-size: 11px; padding: 4px 8px; background: var(--input-bg); border-radius: 6px; color: var(--text-secondary); border: 1px solid var(--glass-border); }

.progress-wrapper { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.progress-bg { flex: 1; height: 6px; background: var(--input-bg); border-radius: 10px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent-color); border-radius: 10px; transition: width 0.3s; }
.progress-text { font-size: 13px; font-weight: 500; color: var(--text-color); min-width: 60px; text-align: right; }

.notes-box { margin-top: 12px; padding: 12px; background: var(--input-bg); border-radius: 8px; font-size: 14px; line-height: 1.4; color: var(--text-secondary); display: none; font-style: italic; }
.notes-box.show { display: block; }

/* --- NAV --- */
.bottom-nav { top: auto; bottom: 0; border-bottom: none; border-top: 0.5px solid var(--glass-border); height: var(--nav-height); justify-content: space-around; }
.nav-btn { background: none; border: none; color: var(--text-secondary); display: flex; flex-direction: column; align-items: center; font-size: 10px; gap: 4px; cursor: pointer; padding: 5px 20px; }
.nav-btn.active { color: var(--accent-color); }

/* --- MODAL --- */
.modal-overlay { 
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; 
    background: rgba(0,0,0,0.6); z-index: 3000;
    display: flex; align-items: center; justify-content: center; 
    backdrop-filter: blur(5px); 
}
.modal-content { width: 90%; max-width: 320px; position: relative; }
.modal-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.separator { height: 1px; background: var(--glass-border); margin: 5px 0; }
