@import url('theme.css');

/**
 * Read with Me - Global Styles
 * High-contrast, accessible design for seniors & kids
 */

:root {
    /* Map old variables to new theme or keep specific overrides if needed */
    --primary-color: var(--accent-primary);
    --bg-light: var(--bg-body);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-dark);
    background: var(--bg-body);
    padding-bottom: calc(var(--nav-height) + 20px);
    /* Space for bottom nav */
}

/* --- Layout Components --- */

/* Header */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 0 var(--page-padding);
    /* Remove vertical padding to let logo dictate */
    height: 70px;
    /* Fixed height for consistency */
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-soft);
}

.app-logo {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 5px;
    height: 85px;
    max-width: 200px;
    /* Prevent massive image expansion */
    width: auto;
    object-fit: contain;
    border-radius: 20px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    background: white;
    padding: 4px;
    z-index: 101;
}

.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.icon-btn {
    font-size: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-dark);
}

.avatar-small {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #eee;
    object-fit: cover;
}

/* Shelves */
.dashboard-container {
    padding: var(--page-padding) 0;
    max-width: 100vw;
    overflow-x: hidden;
}

.shelf-section {
    margin-bottom: 2rem;
}

.shelf-header {
    padding: 0 var(--page-padding);
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.shelf-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-dark);
}

.shelf-scroll {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding: 0 var(--page-padding) 1rem var(--page-padding);
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    /* Firefox */
}

.shelf-scroll::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

/* Book Cards (Tiles) */
.book-tile {
    flex: 0 0 140px;
    /* Fixed width for tiles */
    scroll-snap-align: start;
    position: relative;
    border-radius: var(--radius-sm);
    /* box-shadow: var(--shadow-card); Removed shadow from container since image has it */
    transition: transform 0.2s;
    /* background: var(--bg-card); */
    /* aspect-ratio: 1; REMOVED to allow title */
    /* overflow: hidden; REMOVED to allow title */
    cursor: pointer;
    padding-bottom: 5px;
}

.book-tile:active {
    transform: scale(0.95);
}

.book-tile img {
    width: 140px;
    height: 140px;
    /* Force square aspect ratio */
    object-fit: cover;
    border-radius: 12px;
    /* Apply radius to image since parent no longer clips overflow */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    /* Shadow on image */
}

.book-title-small {
    margin-top: 5px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dark);
    text-align: center;
    /* Multi-line truncation */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
    /* Allow wrapping */
    max-width: 100%;
    line-height: 1.2;
}

/* Big Plus Button */
.add-book-card {
    flex: 0 0 140px;
    height: 140px;
    /* Match aspect ratio of tiles */
    background: linear-gradient(135deg, #FF6B6B, #FF8E8E);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    box-shadow: var(--shadow-card);
    cursor: pointer;
    scroll-snap-align: start;
}

.add-btn-icon {
    font-size: 3rem;
    line-height: 1;
    margin-bottom: 0.2rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.add-btn-text {
    font-weight: 700;
    font-size: 0.9rem;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--nav-height);
    background: var(--nav-bg);
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--nav-inactive);
    font-size: 0.75rem;
    transition: color 0.3s;
}

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

.nav-item.active .nav-icon {
    transform: translateY(-2px);
    color: var(--accent-secondary);
}

.nav-icon {
    font-size: 1.5rem;
    margin-bottom: 4px;
    transition: transform 0.2s;
}

.nav-center-btn {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #4ECDC4, #26A69A);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 1.8rem;
    box-shadow: 0 4px 12px rgba(78, 205, 196, 0.4);
    transform: translateY(-12px);
    border: 4px solid var(--bg-body);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: flex-end;
    /* Slide up from bottom */
    opacity: 0;
    transition: opacity 0.3s;
}

.modal-overlay.visible {
    display: flex;
    opacity: 1;
}

.modal-sheet {
    background: white;
    width: 100%;
    max-width: 600px;
    /* Tablet constraint */
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 2rem;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.modal-overlay.visible .modal-sheet {
    transform: translateY(0);
}

.book-detail-header {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.book-detail-cover {
    width: 120px;
    height: 120px;
    border-radius: var(--radius-md);
    object-fit: cover;
    box-shadow: var(--shadow-card);
}

.book-detail-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.book-detail-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.book-detail-meta {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.action-btn {
    padding: 1rem;
    border-radius: var(--radius-md);
    border: none;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-play-large {
    grid-column: 1 / -1;
    background: var(--accent-secondary);
    color: white;
    font-size: 1.2rem;
    padding: 1.2rem;
}

.btn-secondary {
    background: #f1f2f6;
    color: var(--text-dark);
}


/* --- Profile Switcher (Refactored from inline) --- */

/* --- Animations & Desktop Polish --- */
@media (hover: hover) {
    .book-tile {
        transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    .book-tile:hover {
        transform: translateY(-8px) scale(1.02);
        z-index: 10;
    }

    .nav-item {
        transition: transform 0.2s, color 0.2s;
    }

    .nav-item:hover {
        transform: translateY(-2px);
        color: var(--accent-primary);
    }

    .action-btn {
        transition: transform 0.2s, background 0.2s;
    }

    .action-btn:hover {
        transform: scale(1.02);
    }
}

/* --- Community Shelf Redesign --- */
.community-shelf-header {
    text-align: center;
    padding: 1rem;
    margin-bottom: 0.5rem;
}

.community-shelf-text {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* --- Nav Specifics --- */
.nav-center-btn {
    /* Override gradient with solid color per user request */
    background: #ff6b6b !important;
    border: 4px solid var(--bg-body);
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

.profile-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 50px;
    transition: background 0.2s;
}

.profile-switcher:hover {
    background: rgba(0, 0, 0, 0.03);
}

.profile-switcher img.avatar-small {
    width: 36px !important;
    height: 36px !important;
    border-radius: 50%;
    object-fit: cover;
}

.profile-caret {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.profile-menu {
    position: absolute;
    top: 70px;
    right: 20px;
    background: white;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-card);
    width: 240px;
    padding: 0.5rem 0;
    z-index: 1000;
    display: none;
    animation: fadeIn 0.2s ease-out;
}

.profile-menu.visible {
    display: block;
}

.menu-header {
    padding: 0.8rem 1rem 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.profile-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 0.8rem 1rem;
    border: none;
    background: none;
    text-align: left;
    font-size: 1rem;
    color: var(--text-dark);
    cursor: pointer;
    transition: background 0.1s;
    text-decoration: none;
    box-sizing: border-box;
}

.profile-option:hover {
    background: #f8f9fa;
}

.profile-option.active {
    background: #eef2ff;
    color: #4f46e5;
    font-weight: 600;
}

.profile-option.logout {
    color: var(--accent-primary);
}

.mini-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.mini-avatar.add {
    background: #f1f2f6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: var(--text-muted);
    border: none;
}

.menu-divider {
    height: 1px;
    background: #f1f2f6;
    margin: 0.5rem 0;
}

/* --- Search Modal Improvements --- */
#searchResults div {
    padding: 12px;
    border-bottom: 1px solid #f1f2f6;
    cursor: pointer;
    transition: background 0.2s;
}

#searchResults div:hover {
    background: #f8f9fa;
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hamburger Menu Overrides */
#hamburgerMenu {
    width: 280px;
    padding: 1rem 0;
}

#hamburgerMenu .menu-header {
    padding-left: 1.5rem;
}

#hamburgerMenu .profile-option {
    padding-left: 1.5rem;
}

/* Ensure buttons in nav match links */
button.nav-item {
    background: none;
    border: none;
    font-family: inherit;
    width: 100%;
    /* Ensure click target size */
}

/* Store Modal - specific tweaks if needed, inheriting from generic modal */
#storeModal .modal-sheet {
    max-width: 500px;
    margin: 0 auto;
}