/* ============================================
   BOOKTOPIA - Shared Styles
   style.css — used across all pages
   ============================================ */

/* ---------- Google Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600;700&family=Poppins:wght@400;500;600&display=swap');

/* ---------- Reset ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ---------- Design Tokens ---------- */
:root {
    /* Colors */
    --primary:      #FF6B9D;
    --primary-dark: #e8527f;
    --secondary:    #FFC233;
    --accent:       #67E8F9;
    --purple:       #C084FC;
    --green:        #4ADE80;
    --red:          #F87171;

    /* Backgrounds */
    --bg-page:  linear-gradient(135deg, #FFF5F7 0%, #FFF0F5 50%, #F0F9FF 100%);
    --bg-light: #FFF5F7;
    --bg-card:  #FFFFFF;

    /* Text */
    --text-dark:  #2D3748;
    --text-light: #718096;

    /* Shadows */
    --shadow:       0 10px 30px rgba(255, 107, 157, 0.15);
    --shadow-hover: 0 15px 40px rgba(255, 107, 157, 0.25);
    --shadow-sm:    0 4px 12px rgba(0, 0, 0, 0.08);

    /* Spacing */
    --page-pad: 20px;
    --card-rad: 25px;
    --btn-rad:  15px;

    /* Typography */
    --font-display: 'Fredoka', cursive;
    --font-body:    'Poppins', sans-serif;
}

/* ---------- Base ---------- */
body {
    font-family: var(--font-body);
    background: var(--bg-page);
    min-height: 100vh;
    color: var(--text-dark);
    padding-bottom: 80px; /* space for bottom nav */
}

/* ---------- Typography ---------- */
.font-display { font-family: var(--font-display); }

h1, h2, h3 { font-family: var(--font-display); }

.section-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ---------- Cards ---------- */
.card {
    background: var(--bg-card);
    border-radius: var(--card-rad);
    padding: 25px;
    margin: var(--page-pad);
    box-shadow: var(--shadow);
}

/* ---------- Buttons ---------- */
.btn {
    padding: 15px 30px;
    border: none;
    border-radius: var(--btn-rad);
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-display);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Ripple effect on all buttons */
.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}
.btn:hover::after  { width: 300px; height: 300px; }
.btn:active        { transform: scale(0.97); }

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--purple) 100%);
    color: white;
}
.btn-primary:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }

.btn-secondary {
    background: white;
    color: var(--primary);
    border: 2.5px solid var(--primary);
}
.btn-secondary:hover { background: var(--bg-light); transform: translateY(-2px); }

.btn-success {
    background: linear-gradient(135deg, var(--green) 0%, #22c55e 100%);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, var(--red) 0%, #dc2626 100%);
    color: white;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
    border-radius: 10px;
}

.btn-icon {
    padding: 10px;
    border-radius: 12px;
    aspect-ratio: 1;
}

/* ---------- Inputs ---------- */
input[type="text"],
input[type="number"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 15px;
    border: 3px solid var(--accent);
    border-radius: var(--btn-rad);
    font-size: 1rem;
    font-family: var(--font-body);
    color: var(--text-dark);
    background: white;
    transition: all 0.3s ease;
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 5px rgba(255, 107, 157, 0.1);
}

.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.input-group input { flex: 1; }

/* ---------- Status Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: var(--font-display);
}

.badge-available  { background: #D1FAE5; color: #065F46; }
.badge-reading    { background: #FEF3C7; color: #92400E; }
.badge-reserved   { background: #EDE9FE; color: #5B21B6; }
.badge-borrowed   { background: #FEE2E2; color: #991B1B; }
.badge-completed  { background: #D1FAE5; color: #065F46; }

/* ---------- Header ---------- */
.site-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--purple) 100%);
    color: white;
    padding: 20px var(--page-pad);
    text-align: center;
    box-shadow: 0 4px 20px rgba(255, 107, 157, 0.3);
    position: sticky;
    top: 0;
    z-index: 200;
    animation: slideDown 0.6s ease-out;
}

.site-header h1 {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 700;
    text-shadow: 2px 2px 10px rgba(0,0,0,0.2);
    line-height: 1.1;
}

.site-header .tagline {
    font-size: 1rem;
    font-weight: 500;
    opacity: 0.9;
    margin-top: 3px;
}

.site-header .page-subtitle {
    font-size: 0.85rem;
    opacity: 0.8;
    margin-top: 5px;
}

/* ---------- Bottom Nav ---------- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 2px solid var(--bg-light);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 10px 0 14px;
    z-index: 200;
    box-shadow: 0 -4px 20px rgba(255, 107, 157, 0.12);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    color: var(--text-light);
    font-size: 0.7rem;
    font-family: var(--font-display);
    transition: all 0.2s ease;
    padding: 4px 12px;
    border-radius: 12px;
}

.nav-item .nav-icon { font-size: 1.5rem; }

.nav-item:hover,
.nav-item.active {
    color: var(--primary);
    background: var(--bg-light);
}

.nav-item.active .nav-icon {
    animation: navPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes navPop {
    from { transform: scale(0.8); }
    to   { transform: scale(1); }
}

/* ---------- Didiba Widget ---------- */
.didiba-card {
    background: white;
    border-radius: var(--card-rad);
    padding: 20px;
    margin: var(--page-pad);
    box-shadow: var(--shadow);
    text-align: center;
    position: relative;
    overflow: hidden;
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

/* Soft rotating glow behind Didiba */
.didiba-card::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(circle, rgba(255, 194, 51, 0.08) 0%, transparent 70%);
    animation: rotateSlow 20s linear infinite;
    pointer-events: none;
}

.panda-emoji {
    font-size: 3.5rem;
    display: inline-block;
    animation: pandaBounce 2.2s ease-in-out infinite;
    position: relative;
    z-index: 1;
}

.didiba-message {
    font-family: var(--font-display);
    font-size: 1.15rem;
    color: var(--primary);
    margin-top: 8px;
    font-weight: 600;
    position: relative;
    z-index: 1;
    min-height: 1.6em;
    transition: opacity 0.2s;
}

/* ---------- Stats Bar ---------- */
.stats-bar {
    background: white;
    border-radius: var(--card-rad);
    padding: 20px;
    margin: var(--page-pad);
    margin-top: 0;
    box-shadow: var(--shadow);
    display: grid;
    gap: 10px;
    animation: fadeInUp 0.8s ease-out 0.35s both;
}

.stats-bar.cols-3 { grid-template-columns: repeat(3, 1fr); }
.stats-bar.cols-4 { grid-template-columns: repeat(4, 1fr); }

.stat-item { text-align: center; }

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    font-family: var(--font-display);
    background: linear-gradient(135deg, var(--primary) 0%, var(--purple) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-light);
    margin-top: 4px;
}

/* ---------- Book Card ---------- */
.book-card {
    background: white;
    border-radius: 20px;
    padding: 15px;
    box-shadow: var(--shadow);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: pointer;
    animation: scaleIn 0.5s ease-out both;
    display: flex;
    flex-direction: column;
}

.book-card:hover {
    transform: translateY(-10px) scale(1.03);
    box-shadow: var(--shadow-hover);
}

.book-cover {
    width: 100%;
    height: 190px;
    object-fit: cover;
    border-radius: 12px;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--purple) 100%);
    display: block;
}

.book-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 3px;
    color: var(--text-dark);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
    flex: 1;
}

.book-author {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-added-by {
    font-size: 0.75rem;
    color: var(--purple);
    font-weight: 600;
    margin-bottom: 8px;
}

/* Status buttons row on book card */
.status-group {
    display: flex;
    gap: 4px;
    margin-top: auto;
}

.status-btn {
    flex: 1;
    padding: 7px 4px;
    border: 2px solid transparent;
    border-radius: 10px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: var(--font-display);
    font-weight: 600;
    line-height: 1;
}

.status-btn:hover { transform: scale(1.06); box-shadow: var(--shadow-sm); }

.status-btn.style-unread   { background: #F3F4F6; color: #6B7280; }
.status-btn.style-reading  { background: var(--secondary); color: #7C4B00; border-color: var(--secondary); }
.status-btn.style-completed{ background: var(--green);     color: #065F46; border-color: var(--green); }

/* ---------- Library Grid ---------- */
.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 18px;
    margin-top: 15px;
}

/* ---------- User Picker Grid ---------- */
.user-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 12px;
}

.user-btn {
    padding: 14px 10px;
    border: 3px solid transparent;
    border-radius: 15px;
    background: linear-gradient(135deg, var(--bg-light) 0%, white 100%);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    font-family: var(--font-display);
    font-size: 0.95rem;
}

.user-btn:hover { transform: translateY(-4px); box-shadow: var(--shadow); }

.user-btn.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, var(--primary) 0%, var(--purple) 100%);
    color: white;
    transform: scale(1.05);
}

.user-icon { font-size: 2rem; display: block; margin-bottom: 4px; }

/* ---------- Loading Spinner ---------- */
.loading-indicator {
    display: none;
    text-align: center;
    padding: 20px;
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--primary);
}

.loading-indicator.active { display: block; }

.spinner {
    display: inline-block;
    width: 38px; height: 38px;
    border: 4px solid var(--bg-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin-bottom: 8px;
}

/* ---------- Success Overlay ---------- */
.success-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 107, 157, 0.95);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.success-overlay.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.success-content {
    text-align: center;
    color: white;
    padding: 30px;
    animation: popIn 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.success-content .big-emoji {
    font-size: 5rem;
    display: block;
    margin-bottom: 15px;
}

.success-content h2 {
    font-size: 2.2rem;
    margin-bottom: 8px;
}

.success-content p { font-size: 1.1rem; opacity: 0.9; }

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.empty-state .big-emoji {
    font-size: 5rem;
    display: block;
    margin-bottom: 15px;
    opacity: 0.45;
}

.empty-state h3 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    margin-bottom: 8px;
    color: var(--text-dark);
}

/* ---------- Toast Notification ---------- */
#toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--text-dark);
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-family: var(--font-display);
    opacity: 0;
    transition: all 0.35s ease;
    z-index: 500;
    white-space: nowrap;
    pointer-events: none;
}

#toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ---------- Confetti Particle ---------- */
.confetti-piece {
    position: fixed;
    width: 10px; height: 10px;
    border-radius: 2px;
    animation: confettiFall 2.8s linear forwards;
    z-index: 999;
    pointer-events: none;
}

/* ---------- Animations ---------- */
@keyframes slideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to   { transform: translateY(0);     opacity: 1; }
}

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

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

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

@keyframes popIn {
    from { transform: scale(0.5); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

@keyframes pandaBounce {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    50%       { transform: translateY(-14px) rotate(2deg); }
}

@keyframes rotateSlow {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

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

@keyframes navPop {
    from { transform: scale(0.8); }
    to   { transform: scale(1); }
}

@keyframes confettiFall {
    to { transform: translateY(100vh) rotate(540deg); opacity: 0; }
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: var(--shadow); }
    50%       { box-shadow: 0 0 0 8px rgba(255, 107, 157, 0.12), var(--shadow-hover); }
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
    .site-header h1 { font-size: 1.9rem; }

    .library-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 14px;
    }

    .book-cover { height: 170px; }

    .stats-bar.cols-4 { grid-template-columns: repeat(2, 1fr); }

    .btn { padding: 13px 22px; }
}

@media (min-width: 768px) {
    .library-grid {
        grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    }
    :root { --page-pad: 28px; }
}
