/* Custom Styles for BookStore */

:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --light-color: #f8f9fa;
    --dark-color: #212529;
}

* {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    max-width: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    max-width: 100%;
    position: relative;
}

main {
    flex: 1;
    overflow-x: hidden;
    max-width: 100%;
}

.container {
    max-width: 100%;
    overflow-x: hidden;
}

.row {
    margin-left: 0;
    margin-right: 0;
    max-width: 100%;
}

.row > * {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

/* Card Styles */
.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.card-img-top {
    height: 250px;
    object-fit: cover;
    border-radius: 0.375rem 0.375rem 0 0;
}

/* Book Card Styles */
.book-card {
    height: 100%;
}

.book-card .card-body {
    display: flex;
    flex-direction: column;
}

.book-card .card-title {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0.5rem;
    color: var(--dark-color);
}

.book-card .card-text {
    font-size: 0.9rem;
    color: var(--secondary-color);
    flex-grow: 1;
}

.book-card .price {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.book-card .original-price {
    text-decoration: line-through;
    color: var(--secondary-color);
    font-size: 0.9rem;
    margin-right: 0.5rem;
}

.book-card .discount-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: var(--danger-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Button Styles */
.btn {
    border-radius: 0.375rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: #0b5ed7;
    border-color: #0a58ca;
    transform: translateY(-1px);
}

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

/* Navigation Styles */
.navbar-brand {
    font-size: 1.5rem;
    font-weight: 700;
}

.navbar-nav .nav-link {
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: color 0.2s ease;
}

.navbar-nav .nav-link:hover {
    color: rgba(255, 255, 255, 0.8) !important;
}

/* Hero Section */
.hero-section {
    background: linear-gradient(135deg, var(--primary-color), #0b5ed7);
    color: white;
    padding: 4rem 0;
    margin-bottom: 3rem;
}

.hero-section h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.hero-section p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
}

/* Search Bar */
.search-container {
    max-width: 500px;
    margin: 0 auto 2rem;
}

.search-container .input-group {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.search-container .form-control {
    border-right: none;
    padding: 0.75rem 1rem;
}

.search-container .btn {
    border-left: none;
    padding: 0.75rem 1.5rem;
}

/* Filter Sidebar */
.filter-sidebar {
    background-color: white;
    border-radius: 0.375rem;
    padding: 1.5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    height: fit-content;
    position: sticky;
    top: 1rem;
}

.filter-sidebar h5 {
    color: var(--dark-color);
    margin-bottom: 1rem;
    font-weight: 600;
}

.filter-sidebar .form-check {
    margin-bottom: 0.5rem;
}

.filter-sidebar .form-check-label {
    font-size: 0.9rem;
    color: var(--dark-color);
}

/* Cart Styles */
.cart-item {
    border-bottom: 1px solid #dee2e6;
    padding: 1rem 0;
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-item img {
    width: 80px;
    height: 100px;
    object-fit: cover;
    border-radius: 0.25rem;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.quantity-controls .btn {
    width: 30px;
    height: 30px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.quantity-controls input {
    width: 60px;
    text-align: center;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    padding: 0.25rem;
}

/* Order Summary */
.order-summary {
    background-color: white;
    border-radius: 0.375rem;
    padding: 1.5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    position: sticky;
    top: 1rem;
}

.order-summary h5 {
    color: var(--dark-color);
    margin-bottom: 1rem;
    font-weight: 600;
}

.order-summary .summary-line {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.order-summary .summary-line.total {
    font-weight: 600;
    font-size: 1.1rem;
    border-top: 1px solid #dee2e6;
    padding-top: 0.5rem;
    margin-top: 1rem;
    margin-bottom: 1rem;
}

/* Status Badges */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-pending {
    background-color: #fff3cd;
    color: #856404;
}

.status-confirmed {
    background-color: #d1ecf1;
    color: #0c5460;
}

.status-processing {
    background-color: #d4edda;
    color: #155724;
}

.status-shipped {
    background-color: #cce5ff;
    color: #004085;
}

.status-delivered {
    background-color: #d4edda;
    color: #155724;
}

.status-cancelled {
    background-color: #f8d7da;
    color: #721c24;
}

/* Forms */
.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design */

/* Prevent horizontal scroll on all devices */
.overflow-hidden {
    overflow: hidden !important;
}

img {
    max-width: 100%;
    height: auto;
}

/* Fix for orders page and cards */
.order-card,
.card {
    max-width: 100%;
    overflow: hidden;
}

.order-item {
    max-width: 100%;
    overflow-x: hidden;
}

/* Better table handling */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

table {
    max-width: 100%;
}

@media (max-width: 992px) {
    /* Tablet adjustments */
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .card-img-top {
        height: 220px;
    }
}

@media (max-width: 768px) {
    /* Mobile landscape */
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
        position: relative;
    }
    
    .hero-section h1 {
        font-size: 2rem;
    }
    
    .hero-section p {
        font-size: 1rem;
    }
    
    .card-img-top {
        height: 200px;
    }
    
    .filter-sidebar {
        margin-bottom: 2rem;
        position: static;
    }
    
    .cart-item img {
        width: 60px;
        height: 75px;
    }
    
    /* Better table responsiveness */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Adjust padding for mobile */
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        max-width: 100%;
    }
    
    /* Stack columns on mobile */
    .row > [class*='col-'] {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
        max-width: 100%;
    }
    
    /* Better button sizes on mobile */
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.95rem;
    }
    
    .btn-sm {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }
    
    /* Fix orders page for mobile */
    .order-details {
        flex-direction: column;
    }
    
    .order-header {
        flex-direction: column;
        align-items: flex-start !important;
    }
    
    .order-header > div {
        width: 100%;
        text-align: left !important;
        margin-bottom: 1rem;
    }
    
    /* Better order items display */
    .order-item {
        flex-direction: column !important;
        align-items: flex-start !important;
    }
    
    .order-item > div {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 576px) {
    /* Mobile portrait */
    html, body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
        width: 100%;
    }
    
    * {
        max-width: 100%;
    }
    
    .hero-section {
        padding: 1.5rem 0;
    }
    
    .hero-section h1 {
        font-size: 1.5rem;
        line-height: 1.3;
        word-wrap: break-word;
    }
    
    .hero-section p {
        font-size: 0.9rem;
    }
    
    .search-container {
        margin-bottom: 1rem;
    }
    
    .card-img-top {
        height: 180px;
    }
    
    /* Better spacing on small screens */
    .container {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
        max-width: 100vw;
        overflow-x: hidden;
    }
    
    /* Adjust card spacing */
    .card {
        margin-bottom: 1rem;
        max-width: 100%;
    }
    
    .card-body {
        padding: 0.75rem;
    }
    
    .card-title {
        font-size: 1rem !important;
        word-wrap: break-word;
    }
    
    .card-text {
        font-size: 0.85rem !important;
    }
    
    /* Better form inputs on mobile */
    .form-control,
    .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.65rem 0.75rem;
        max-width: 100%;
    }
    
    /* Adjust buttons for thumb-friendly taps */
    .btn {
        min-height: 44px; /* Apple's recommended tap target */
        padding: 0.65rem 1rem;
        width: auto;
        max-width: 100%;
    }
    
    /* Better navbar on mobile */
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    .nav-link {
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }
    
    /* Improve checkout/cart on mobile */
    .checkout-summary,
    .cart-summary {
        position: static;
        margin-top: 1rem;
        max-width: 100%;
    }
    
    /* Better footer spacing */
    footer {
        font-size: 0.875rem;
        overflow-x: hidden;
    }
    
    footer .col-md-3,
    footer .col-md-4 {
        margin-bottom: 1.5rem;
    }
    
    /* Hide unnecessary elements on very small screens */
    .d-xs-none {
        display: none !important;
    }
    
    /* Make tables scroll horizontally */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        max-width: 100%;
    }
    
    /* Better book grid on mobile */
    .book-card .card-img-top {
        height: 160px;
    }
    
    /* Price adjustments */
    .price {
        font-size: 1.1rem !important;
    }
    
    /* Better order items display - CRITICAL FIX */
    .order-item {
        flex-direction: column !important;
        align-items: flex-start !important;
        width: 100%;
        max-width: 100%;
    }
    
    .order-item img {
        width: 100%;
        max-width: 150px;
        height: auto;
        margin-bottom: 0.5rem;
    }
    
    .order-item > * {
        width: 100%;
        max-width: 100%;
    }
    
    /* Fix order cards */
    .order-card {
        margin-bottom: 1rem;
        overflow: hidden;
        max-width: 100%;
    }
    
    .order-card .flex {
        flex-direction: column;
        align-items: flex-start !important;
    }
    
    .order-card .text-right {
        text-align: left !important;
        width: 100%;
        margin-top: 1rem;
    }
    
    /* Fix gradient backgrounds that cause overflow */
    .bg-gradient-to-r,
    .bg-gradient-to-br {
        max-width: 100%;
        overflow: hidden;
    }
    
    /* Fix rounded cards */
    .rounded-3xl,
    .rounded-2xl,
    .rounded-xl {
        border-radius: 1rem !important;
    }
    
    /* Fix flex layouts */
    .flex {
        flex-wrap: wrap;
    }
    
    .space-x-4 > * {
        margin-right: 0 !important;
        margin-bottom: 0.5rem;
    }
    
    /* Fix text sizes */
    .text-5xl {
        font-size: 2rem !important;
    }
    
    .text-4xl {
        font-size: 1.75rem !important;
    }
    
    .text-3xl {
        font-size: 1.5rem !important;
    }
    
    .text-2xl {
        font-size: 1.25rem !important;
    }
    
    .text-xl {
        font-size: 1.1rem !important;
    }
    
    /* Fix padding issues */
    .p-8 {
        padding: 1rem !important;
    }
    
    .p-6 {
        padding: 0.75rem !important;
    }
    
    .p-4 {
        padding: 0.5rem !important;
    }
    
    .px-8 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    .py-8 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
}

@media (max-width: 375px) {
    /* Extra small devices (small phones) */
    .hero-section h1 {
        font-size: 1.25rem;
    }
    
    .card-img-top {
        height: 150px;
    }
    
    .btn {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
    }
    
    .container {
        padding-left: 0.25rem;
        padding-right: 0.25rem;
    }
}

/* Print Styles */
@media print {
    .navbar,
    .btn,
    footer {
        display: none !important;
    }
    
    .container {
        max-width: none !important;
    }
}

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus styles for better accessibility */
.btn:focus,
.form-control:focus,
.form-select:focus,
.nav-link:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Animation classes */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.slide-up {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}