/* Apple Liquid Glass Design System */
/* Inspired by iOS 15+ and macOS Monterey+ design language */

:root {
    /* Liquid Glass Color Palette */
    --glass-white: rgba(255, 255, 255, 0.1);
    --glass-white-strong: rgba(255, 255, 255, 0.15);
    --glass-white-subtle: rgba(255, 255, 255, 0.05);
    --glass-dark: rgba(0, 0, 0, 0.1);
    --glass-dark-strong: rgba(0, 0, 0, 0.15);
    --glass-accent: rgba(102, 126, 234, 0.1);
    --glass-accent-strong: rgba(102, 126, 234, 0.15);
    
    /* Blur Values */
    --blur-subtle: blur(8px);
    --blur-medium: blur(16px);
    --blur-strong: blur(24px);
    --blur-extreme: blur(40px);
    
    /* Shadows */
    --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.12);
    --shadow-glass-strong: 0 16px 64px rgba(0, 0, 0, 0.16);
    --shadow-glass-subtle: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-inner: inset 0 1px 0 rgba(255, 255, 255, 0.2);
    
    /* Border Radius */
    --radius-glass: 16px;
    --radius-glass-large: 24px;
    --radius-glass-small: 12px;
    
    /* Transitions */
    --transition-glass: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --transition-bounce: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Base Glassmorphism Mixin */
.glass-base {
    backdrop-filter: var(--blur-medium);
    -webkit-backdrop-filter: var(--blur-medium);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-glass);
    transition: var(--transition-glass);
}

.glass-white {
    background: var(--glass-white);
}

.glass-white-strong {
    background: var(--glass-white-strong);
}

.glass-dark {
    background: var(--glass-dark);
}

.glass-accent {
    background: var(--glass-accent);
}

/* Navigation Glass Effect */
.nav-glass {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.9) 0%, rgba(118, 75, 162, 0.9) 100%);
    backdrop-filter: var(--blur-strong);
    -webkit-backdrop-filter: var(--blur-strong);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-glass);
    transition: var(--transition-glass);
}

/* Chapter Cards Glass Effect */
.chapter-card-glass {
    background: #ffffff !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border-radius: var(--radius-glass);
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1) !important;
    position: relative;
    overflow: hidden;
    transition: var(--transition-glass);
    opacity: 1 !important;
    visibility: visible !important;
    display: block !important;
    z-index: 1 !important;
    min-height: 200px !important;
    color: #1f2937 !important;
}

.chapter-card-glass::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(255, 255, 255, 0.4) 50%, 
        transparent 100%);
}

.chapter-card-glass:hover {
    background: linear-gradient(145deg, 
        rgba(255, 255, 255, 0.15) 0%, 
        rgba(255, 255, 255, 0.08) 100%);
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.chapter-card-glass:active {
    transform: translateY(-2px) scale(1.01);
    transition: all 0.1s ease;
}

/* Glass Buttons */
.btn-glass {
    @extend .glass-base;
    background: linear-gradient(145deg, 
        rgba(255, 255, 255, 0.12) 0%, 
        rgba(255, 255, 255, 0.06) 100%);
    border-radius: var(--radius-glass-small);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(0, 0, 0, 0.8);
    font-weight: 500;
    padding: 12px 24px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    user-select: none;
}

.btn-glass::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.2), 
        transparent);
    transition: left 0.5s;
}

.btn-glass:hover {
    background: linear-gradient(145deg, 
        rgba(255, 255, 255, 0.18) 0%, 
        rgba(255, 255, 255, 0.1) 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glass-strong);
    border-color: rgba(255, 255, 255, 0.3);
}

.btn-glass:hover::before {
    left: 100%;
}

.btn-glass:active {
    transform: translateY(0);
    background: linear-gradient(145deg, 
        rgba(255, 255, 255, 0.08) 0%, 
        rgba(255, 255, 255, 0.04) 100%);
}

/* Primary Glass Button */
.btn-glass-primary {
    @extend .btn-glass;
    background: linear-gradient(145deg, 
        rgba(102, 126, 234, 0.15) 0%, 
        rgba(102, 126, 234, 0.08) 100%);
    border: 1px solid rgba(102, 126, 234, 0.3);
    color: rgba(102, 126, 234, 1);
}

.btn-glass-primary:hover {
    background: linear-gradient(145deg, 
        rgba(102, 126, 234, 0.25) 0%, 
        rgba(102, 126, 234, 0.15) 100%);
    border-color: rgba(102, 126, 234, 0.4);
}

/* Progress Bar Glass */
.progress-glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: var(--blur-subtle);
    -webkit-backdrop-filter: var(--blur-subtle);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    overflow: hidden;
    position: relative;
}

.progress-glass-fill {
    background: linear-gradient(90deg, 
        rgba(102, 126, 234, 0.8) 0%, 
        rgba(118, 75, 162, 0.8) 100%);
    height: 100%;
    border-radius: 7px;
    position: relative;
    overflow: hidden;
}

.progress-glass-fill::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.3), 
        transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Modal Glass Effect */
.modal-glass {
    @extend .glass-base;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: var(--blur-strong);
    -webkit-backdrop-filter: var(--blur-strong);
    border-radius: var(--radius-glass-large);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: var(--shadow-glass-strong);
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
}

.modal-glass-backdrop {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: var(--blur-medium);
    -webkit-backdrop-filter: var(--blur-medium);
}

/* Input Glass Effect */
.input-glass {
    @extend .glass-base;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-glass-small);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 12px 16px;
    color: rgba(0, 0, 0, 0.8);
    font-size: 16px;
}

.input-glass:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(102, 126, 234, 0.4);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    outline: none;
}

.input-glass::placeholder {
    color: rgba(0, 0, 0, 0.4);
}

/* Notification Glass */
.notification-glass {
    @extend .glass-base;
    background: linear-gradient(145deg, 
        rgba(255, 255, 255, 0.15) 0%, 
        rgba(255, 255, 255, 0.08) 100%);
    border-radius: var(--radius-glass);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 16px 20px;
    margin: 8px 0;
}

.notification-glass.success {
    background: linear-gradient(145deg, 
        rgba(52, 211, 153, 0.15) 0%, 
        rgba(52, 211, 153, 0.08) 100%);
    border-color: rgba(52, 211, 153, 0.3);
}

.notification-glass.error {
    background: linear-gradient(145deg, 
        rgba(248, 113, 113, 0.15) 0%, 
        rgba(248, 113, 113, 0.08) 100%);
    border-color: rgba(248, 113, 113, 0.3);
}

.notification-glass.warning {
    background: linear-gradient(145deg, 
        rgba(251, 191, 36, 0.15) 0%, 
        rgba(251, 191, 36, 0.08) 100%);
    border-color: rgba(251, 191, 36, 0.3);
}

/* Floating Action Button Glass */
.fab-glass {
    background: linear-gradient(145deg, 
        rgba(102, 126, 234, 0.2) 0%, 
        rgba(102, 126, 234, 0.1) 100%);
    backdrop-filter: var(--blur-medium);
    -webkit-backdrop-filter: var(--blur-medium);
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 50%;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    cursor: pointer;
    transition: var(--transition-bounce);
    box-shadow: var(--shadow-glass);
}

.fab-glass:hover {
    transform: scale(1.1) translateY(-2px);
    background: linear-gradient(145deg, 
        rgba(102, 126, 234, 0.3) 0%, 
        rgba(102, 126, 234, 0.15) 100%);
    box-shadow: var(--shadow-glass-strong);
}

.fab-glass:active {
    transform: scale(1.05);
}

/* Sidebar Glass */
.sidebar-glass {
    @extend .glass-base;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: var(--blur-strong);
    -webkit-backdrop-filter: var(--blur-strong);
    border-right: 1px solid rgba(255, 255, 255, 0.3);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
}

/* Mobile Menu Glass */
.mobile-menu {
    background: linear-gradient(135deg, 
        rgba(0, 0, 0, 0.95) 0%, 
        rgba(0, 0, 0, 0.9) 100%);
    backdrop-filter: var(--blur-strong);
    -webkit-backdrop-filter: var(--blur-strong);
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-glass-strong);
    transform: translateX(-100%);
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    overflow-y: auto;
    width: 100%;
}

.mobile-menu.open {
    transform: translateX(0);
}

.close-menu {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: var(--blur-subtle);
    -webkit-backdrop-filter: var(--blur-subtle);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: var(--transition-glass);
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
}

.close-menu:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.close-menu:active {
    transform: scale(0.95);
}

.mobile-menu-link {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: var(--blur-subtle);
    -webkit-backdrop-filter: var(--blur-subtle);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-weight: 500;
    position: relative;
    overflow: hidden;
    display: block;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    margin: 0.5rem 0;
    transition: var(--transition-glass);
}

.mobile-menu-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.1), 
        transparent);
    transition: left 0.5s;
}

.mobile-menu-link:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateX(8px);
    color: rgba(255, 255, 255, 1);
}

.mobile-menu-link:hover::before {
    left: 100%;
}

.mobile-menu-link:active {
    transform: translateX(4px) scale(0.98);
    background: rgba(255, 255, 255, 0.12);
}

.mobile-menu-link i {
    width: 20px;
    text-align: center;
    opacity: 0.8;
}

.mobile-menu-link:hover i {
    opacity: 1;
}

/* Install Banner Glass */
.install-banner-glass {
    backdrop-filter: var(--blur-strong);
    -webkit-backdrop-filter: var(--blur-strong);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-glass-strong);
    animation: slideUpBanner 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes slideUpBanner {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Update Notification Glass */
.update-notification-glass {
    backdrop-filter: var(--blur-strong);
    -webkit-backdrop-filter: var(--blur-strong);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-glass-strong);
    animation: slideInNotification 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

/* PWA Menu Glass */
.pwa-menu-glass {
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: var(--blur-strong);
    -webkit-backdrop-filter: var(--blur-strong);
    background: rgba(0, 0, 0, 0.5);
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
}

.pwa-menu-glass:not(.hidden) {
    display: flex;
}

.pwa-menu-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: var(--blur-medium);
    -webkit-backdrop-filter: var(--blur-medium);
}

.pwa-menu-content {
    background: linear-gradient(135deg, 
        rgba(0, 0, 0, 0.9) 0%, 
        rgba(0, 0, 0, 0.85) 100%);
    backdrop-filter: var(--blur-strong);
    -webkit-backdrop-filter: var(--blur-strong);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-glass-large);
    box-shadow: var(--shadow-glass-strong);
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    position: relative;
    animation: scaleInPWA 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes scaleInPWA {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.pwa-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.close-pwa-menu {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: var(--blur-subtle);
    -webkit-backdrop-filter: var(--blur-subtle);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: var(--transition-glass);
}

.close-pwa-menu:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
    color: rgba(255, 255, 255, 1);
}

.pwa-menu-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.pwa-menu-item {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: var(--blur-subtle);
    -webkit-backdrop-filter: var(--blur-subtle);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-glass);
    color: rgba(255, 255, 255, 0.9);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    transition: var(--transition-glass);
    font-weight: 500;
    text-align: left;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.pwa-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, 
        rgba(102, 126, 234, 0.2) 0%, 
        rgba(118, 75, 162, 0.2) 100%);
    backdrop-filter: var(--blur-subtle);
    -webkit-backdrop-filter: var(--blur-subtle);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    transition: var(--transition-glass);
    flex-shrink: 0;
}

.pwa-icon-wrapper i {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.9);
    transition: var(--transition-glass);
}

.pwa-item-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.pwa-item-title {
    font-size: 1rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    line-height: 1.2;
}

.pwa-item-desc {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.3;
}

.pwa-menu-item:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateX(8px);
    color: rgba(255, 255, 255, 1);
}

.pwa-menu-item:hover .pwa-icon-wrapper {
    background: linear-gradient(135deg, 
        rgba(102, 126, 234, 0.4) 0%, 
        rgba(118, 75, 162, 0.4) 100%);
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.pwa-menu-item:hover .pwa-icon-wrapper i {
    color: rgba(255, 255, 255, 1);
    transform: scale(1.1);
}

.pwa-menu-item:hover .pwa-item-title {
    color: rgba(255, 255, 255, 1);
}

.pwa-menu-item:hover .pwa-item-desc {
    color: rgba(255, 255, 255, 0.8);
}

.pwa-menu-item:active {
    transform: translateX(4px) scale(0.98);
    background: rgba(255, 255, 255, 0.12);
}

.pwa-menu-item i {
    width: 20px;
    text-align: center;
    opacity: 0.8;
    font-size: 1.1rem;
}

.pwa-menu-item:hover i {
    opacity: 1;
}

/* Responsive PWA Menu */
@media (max-width: 768px) {
    .pwa-menu-content {
        padding: 1.5rem;
        max-width: 350px;
    }
    
    .pwa-menu-item {
        padding: 0.875rem 1.25rem;
    }
}

/* Card Stack Glass Effect */
.card-stack-glass {
    position: relative;
}

.card-stack-glass .card {
    @extend .glass-base;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-glass);
    margin-bottom: 16px;
    transform-origin: center;
    transition: var(--transition-glass);
}

.card-stack-glass .card:nth-child(1) {
    transform: translateY(0) scale(1);
    z-index: 3;
}

.card-stack-glass .card:nth-child(2) {
    transform: translateY(-8px) scale(0.98);
    z-index: 2;
    opacity: 0.8;
}

.card-stack-glass .card:nth-child(3) {
    transform: translateY(-16px) scale(0.96);
    z-index: 1;
    opacity: 0.6;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    :root {
        --blur-subtle: blur(6px);
        --blur-medium: blur(12px);
        --blur-strong: blur(18px);
        --radius-glass: 12px;
        --radius-glass-large: 16px;
        --radius-glass-small: 8px;
    }
    
    .chapter-card-glass:hover {
        transform: translateY(-2px) scale(1.01);
    }
    
    .fab-glass {
        width: 48px;
        height: 48px;
        bottom: 16px;
        right: 16px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --glass-white: rgba(255, 255, 255, 0.08);
        --glass-white-strong: rgba(255, 255, 255, 0.12);
        --glass-white-subtle: rgba(255, 255, 255, 0.04);
        --glass-dark: rgba(0, 0, 0, 0.2);
        --glass-dark-strong: rgba(0, 0, 0, 0.3);
    }
    
    .nav-glass {
        background: rgba(0, 0, 0, 0.7);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .chapter-card-glass {
        background: linear-gradient(145deg, 
            rgba(255, 255, 255, 0.08) 0%, 
            rgba(255, 255, 255, 0.04) 100%);
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .btn-glass {
        color: rgba(255, 255, 255, 0.9);
    }
    
    .input-glass {
        color: rgba(255, 255, 255, 0.9);
    }
    
    .input-glass::placeholder {
        color: rgba(255, 255, 255, 0.5);
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .progress-glass-fill::before {
        animation: none;
    }
}
