/**
 * Mobile Responsive Styles
 * Ensures optimal viewing experience across all devices
 */

/* Mobile Navigation Styles */
@media (max-width: 768px) {
    /* Hide desktop navigation */
    nav.hidden.md\\:flex {
        display: none !important;
    }

    /* Mobile menu button */
    .mobile-menu-button {
        display: block;
    }

    /* Search bar adjustments */
    input[name="q"] {
        width: 150px;
        font-size: 14px;
    }

    /* Header adjustments */
    header .container {
        padding: 0.75rem 1rem;
    }

    /* Logo size */
    header .font-bold.text-xl {
        font-size: 1.125rem;
    }
}

/* Mobile Book Cards */
@media (max-width: 640px) {
    /* Stack book cover and details vertically */
    .book-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .book-card .book-cover {
        width: 120px;
        margin-bottom: 1rem;
    }

    /* Adjust book grid */
    .grid-cols-2 {
        grid-template-columns: 1fr;
    }

    /* Book list adjustments */
    .book-list-item {
        padding: 1rem;
    }

    .book-list-item img {
        width: 60px;
        height: 90px;
    }
}

/* Mobile Reading History */
@media (max-width: 640px) {
    /* Stack timeline items */
    .timeline-item {
        padding-left: 2rem;
    }

    .timeline-line {
        left: 0.75rem;
    }

    .timeline-dot {
        left: 0.25rem;
    }

    /* Adjust date display */
    .timeline-date {
        font-size: 0.75rem;
    }

    /* Stack book info in timeline */
    .timeline-book-info {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Mobile Statistics */
@media (max-width: 640px) {
    /* Stack stat cards in single column */
    .stat-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    /* Smaller stat card padding */
    .stat-card {
        padding: 1rem;
    }

    /* Adjust stat numbers */
    .stat-value {
        font-size: 1.75rem;
    }

    /* Mini stats in row */
    .mini-stats {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
}

/* Mobile Tables */
@media (max-width: 768px) {
    /* Convert tables to cards on mobile */
    .responsive-table {
        display: block;
    }

    .responsive-table thead {
        display: none;
    }

    .responsive-table tbody {
        display: block;
    }

    .responsive-table tr {
        display: block;
        border: 1px solid #e5e7eb;
        border-radius: 0.5rem;
        margin-bottom: 0.75rem;
        padding: 0.75rem;
    }

    .responsive-table td {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem 0;
        border: none;
    }

    .responsive-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
    }
}

/* Mobile Modals */
@media (max-width: 640px) {
    /* Full screen modals on mobile */
    .modal-content {
        max-width: 100%;
        margin: 0;
        height: 100vh;
        border-radius: 0;
    }

    /* Adjust modal padding */
    .modal-content > div {
        padding: 1rem;
    }

    /* Stack modal buttons */
    .modal-footer {
        flex-direction: column-reverse;
        gap: 0.5rem;
    }

    .modal-footer button {
        width: 100%;
    }
}

/* Mobile Forms */
@media (max-width: 640px) {
    /* Full width inputs */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    textarea,
    select {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Stack form groups */
    .form-grid {
        grid-template-columns: 1fr;
    }

    /* Larger touch targets */
    button,
    .btn {
        min-height: 44px;
        padding: 0.75rem 1rem;
    }
}

/* Mobile Reviews */
@media (max-width: 640px) {
    /* Stack review header */
    .review-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    /* Smaller avatar */
    .review-avatar {
        width: 2.5rem;
        height: 2.5rem;
    }

    /* Review actions below content */
    .review-actions {
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid #e5e7eb;
    }
}

/* Mobile Badges and Pills */
@media (max-width: 640px) {
    /* Wrap badge groups */
    .badge-group {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    /* Smaller badges */
    .badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
}

/* Mobile Toast Notifications */
@media (max-width: 640px) {
    /* Full width toasts */
    #toast-container {
        left: 0;
        right: 0;
        top: auto;
        bottom: 0;
        padding: 1rem;
    }

    .toast {
        max-width: 100%;
        margin: 0;
    }

    /* Slide up animation on mobile */
    @keyframes mobile-toast-enter {
        from {
            transform: translateY(100%);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }

    .toast-enter {
        animation: mobile-toast-enter 0.3s ease-out forwards;
    }
}

/* Mobile Rating Components */
@media (max-width: 640px) {
    /* Larger touch targets for stars */
    .star-rating button {
        padding: 0.5rem;
    }

    /* Stack rating breakdown */
    .rating-breakdown {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Mobile Progress Bars */
@media (max-width: 640px) {
    /* Thicker progress bars for visibility */
    .progress-bar {
        height: 0.5rem;
    }

    /* Show percentage inside bar if space allows */
    .progress-percentage {
        position: absolute;
        right: 0.5rem;
        top: 50%;
        transform: translateY(-50%);
        font-size: 0.625rem;
        font-weight: 600;
    }
}

/* Mobile Loading States */
@media (max-width: 640px) {
    /* Adjust skeleton sizes */
    .skeleton-book-card {
        padding: 0.75rem;
    }

    /* Loading overlay adjustments */
    .loading-overlay {
        padding: 1rem;
    }

    .loading-overlay p {
        font-size: 0.875rem;
    }
}

/* Touch-specific enhancements */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .hover\\:bg-slate-50:hover {
        background-color: transparent;
    }

    /* Add active states for better feedback */
    button:active,
    a:active {
        opacity: 0.8;
        transform: scale(0.98);
    }

    /* Larger click targets */
    a, button {
        position: relative;
    }

    a::after,
    button::after {
        content: '';
        position: absolute;
        top: -8px;
        right: -8px;
        bottom: -8px;
        left: -8px;
    }
}

/* Landscape mobile adjustments */
@media (max-width: 896px) and (orientation: landscape) {
    /* Reduce header height */
    header {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }

    /* Horizontal scroll for book grids */
    .book-grid-landscape {
        display: flex;
        overflow-x: auto;
        gap: 1rem;
        padding-bottom: 1rem;
    }

    .book-grid-landscape > * {
        flex: 0 0 200px;
    }
}

/* Utility classes for mobile */
@media (max-width: 640px) {
    .mobile\\:hidden {
        display: none !important;
    }

    .mobile\\:block {
        display: block !important;
    }

    .mobile\\:flex {
        display: flex !important;
    }

    .mobile\\:text-sm {
        font-size: 0.875rem !important;
    }

    .mobile\\:px-4 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
}

/* Print styles */
@media print {
    /* Hide navigation and controls */
    header, footer, .no-print {
        display: none !important;
    }

    /* Adjust layout for print */
    .container {
        max-width: 100%;
        margin: 0;
    }

    /* Remove shadows and backgrounds */
    * {
        box-shadow: none !important;
        text-shadow: none !important;
    }

    /* Black text on white */
    body {
        color: black !important;
        background: white !important;
    }
}
