body {
    /* Set the background image */
    background-image: url('Background/bg1.jpeg');
    background-size: cover;
    /* Cover the entire page */
    background-position: center center;
    /* Center the image */
    background-attachment: fixed;
    /* Make the background fixed on scroll */
    background-repeat: no-repeat;
    /* Do not repeat the image */

    color: #fff;
    position: relative;
    /* Required for the overlay */
    z-index: 0;
}

/* Add a dark overlay for better text readability */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(20, 20, 20, 0.95);
    /* Dark overlay with 75% opacity */
    z-index: -1;
    /* Place it behind the content but on top of the background image */
}

/* Mobile-first responsive design */
@media (max-width: 768px) {
    body {
        background-attachment: scroll;
        /* Better performance on mobile */
    }
}

.netflix-red {
    background-color: #e50914;
}

.netflix-red-text {
    color: #e50914;
}

/* Custom scrollbar for a more modern look */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #1f1f1f;
}

::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #e50914;
}

/* Notification Styling */
#notification-container .notification {
    transition: all 0.5s ease-in-out;
}

#notification-container .notification.fade-out {
    opacity: 0;
    transform: translateX(100%);
}

#main-content {
    padding-left: 5rem;
    /* Increased padding to avoid overlap with the new button container */
}

/* Responsive adjustments for main content */
@media (max-width: 768px) {
    #main-content {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* Auth Form Styling */
.auth-container {
    max-width: 500px;
    margin: 8rem auto 0 auto;
    padding: 0 1rem;
}

.auth-form input {
    transition: all 0.3s ease;
}

.auth-form input:focus {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.auth-toggle-link {
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-toggle-link:hover {
    transform: translateY(-1px);
}

/* Enhanced glassmorphism effect */
.table-container-glass {
    background: rgba(31, 41, 55, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Button hover effects */
button {
    transition: all 0.2s ease;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Notification improvements */
.notification {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

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

/* ===== RESPONSIVE DESIGN ===== */

/* Mobile Devices (320px - 768px) */
@media (max-width: 768px) {

    /* Header adjustments */
    header {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    header h1 {
        font-size: 1.25rem;
        order: 1;
    }

    header .relative {
        order: 3;
        width: 100%;
        max-width: none;
        margin: 0;
    }

    header .flex.items-center {
        order: 2;
        gap: 0.5rem;
    }

    #total-count-display {
        font-size: 0.875rem;
    }

    #logout-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    /* Fixed left buttons - make them smaller and repositioned */
    .fixed.top-1\\/2 {
        left: 0.5rem;
        gap: 0.5rem;
    }

    .fixed.top-1\\/2 button {
        padding: 0.5rem;
        width: 2.5rem;
        height: 2.5rem;
    }

    .fixed.top-1\\/2 svg {
        width: 1.25rem;
        height: 1.25rem;
    }

    /* Sidebar adjustments */
    #sidebar {
        width: 85vw;
        max-width: 300px;
    }

    /* Auth container adjustments */
    .auth-container {
        margin-top: 6rem;
        padding: 0 0.5rem;
    }

    .table-container-glass {
        margin: 0.5rem 0;
        padding: 1rem;
    }

    /* Table responsiveness */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
    }

    /* Modal adjustments */
    #modal-content {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
        width: calc(100vw - 2rem);
        max-width: none;
    }

    #modal-content .flex.flex-col.md\\:flex-row {
        flex-direction: column;
    }

    #modal-content img {
        width: 200px;
        margin: 0 auto;
    }

    /* Notification container */
    #notification-container {
        right: 1rem;
        left: 1rem;
        width: auto;
        top: 5rem;
    }

    /* Create container */
    #create-container .flex {
        flex-direction: column;
        gap: 0.5rem;
    }

    #new-category-input {
        width: 100%;
        border-radius: 0.375rem;
    }

    #add-category-btn {
        width: 100%;
        border-radius: 0.375rem;
    }
}

/* Tablet Devices (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    header {
        padding: 1rem 2rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    #main-content {
        padding-left: 3rem;
        padding-right: 2rem;
    }

    #sidebar {
        width: 280px;
    }

    .table-container-glass {
        margin: 1rem 0;
    }

    #modal-content {
        max-width: 90vw;
        margin: 2rem;
    }

    /* Adjust button container for tablet */
    .fixed.top-1\\/2 {
        left: 1rem;
    }
}

/* Large Desktop (1025px+) */
@media (min-width: 1025px) {
    .container {
        max-width: 1200px;
    }

    #main-content {
        padding-left: 6rem;
    }

    .table-container-glass {
        margin: 1.5rem 0;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {

    button,
    .auth-toggle-link {
        min-height: 44px;
        /* Minimum touch target size */
        min-width: 44px;
    }

    input,
    select,
    textarea {
        font-size: 16px;
        /* Prevent zoom on iOS */
    }

    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
    body {
        background-size: cover;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    header {
        padding: 0.5rem 1rem;
    }

    header h1 {
        font-size: 1.125rem;
    }

    .auth-container {
        margin-top: 4rem;
    }

    .fixed.top-1\\/2 {
        top: 40%;
    }
}

/* Print styles */
@media print {
    body::before {
        display: none;
    }

    header,
    .fixed,
    #sidebar,
    #notification-container {
        display: none !important;
    }

    #main-content {
        padding: 0;
        margin: 0;
    }

    .table-container-glass {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
        border: 1px solid #ccc !important;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
button:focus,
input:focus,
select:focus,
textarea:focus,
a:focus {
    outline: 2px solid #ef4444;
    outline-offset: 2px;
}

/* Responsive table layout - no horizontal scroll */
.table-wrapper {
    width: 100%;
    max-width: 100%;
    border-radius: 0.5rem;
    max-height: 70vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.table-wrapper table {
    width: 100%;
    table-layout: fixed;
}

/* Sticky table headers */
.table-wrapper thead th {
    position: sticky;
    top: 0;
    background-color: rgba(31, 41, 55, 0.95);
    backdrop-filter: blur(10px);
    z-index: 10;
    border-bottom: 2px solid #374151;
}

/* Ensure manga names wrap properly */
.table-wrapper td {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* Specific column widths for mobile */
@media (max-width: 768px) {

    .table-wrapper th:nth-child(1),
    .table-wrapper td:nth-child(1) {
        width: 40px;
        /* S.No column */
    }

    .table-wrapper th:nth-child(2),
    .table-wrapper td:nth-child(2) {
        width: 60px;
        /* Cover column */
    }

    .table-wrapper th:nth-child(3),
    .table-wrapper td:nth-child(3) {
        width: auto;
        /* Name column - takes remaining space */
        min-width: 120px;
    }

    .table-wrapper th:nth-child(4),
    .table-wrapper td:nth-child(4) {
        width: 70px;
        /* Chapter column */
    }

    .table-wrapper th:nth-child(5),
    .table-wrapper td:nth-child(5) {
        width: 100px;
        /* Actions column */
    }
}

/* Mobile-specific button adjustments */
@media (max-width: 768px) {
    .btn-mobile-full {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .flex-mobile-col {
        flex-direction: column;
    }

    .gap-mobile-2 {
        gap: 0.5rem;
    }

    /* Compact action buttons for mobile */
    .table-wrapper .grid.grid-cols-2 {
        gap: 2px;
    }

    .table-wrapper .grid.grid-cols-2 button {
        font-size: 10px;
        padding: 2px 4px;
        min-height: 24px;
    }
}

/* Ensure text wrapping in table cells */
.table-wrapper td[contenteditable="true"] {
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    max-width: 0;
    /* This forces the cell to use available space */
}

/* Improve input styling in new entry rows */
.new-entry-row input {
    border: 1px solid #4B5563;
    transition: border-color 0.2s ease;
}

.new-entry-row input:focus {
    border-color: #3B82F6;
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* 
Additional mobile optimizations */
@media (max-width: 480px) {

    /* Very small screens */
    header {
        padding: 0.5rem;
    }

    header h1 {
        font-size: 1rem;
    }

    #search-input {
        font-size: 16px;
        /* Prevent zoom on iOS */
        padding: 0.75rem 0.75rem 0.75rem 2.5rem;
    }

    .auth-container {
        margin-top: 5rem;
        padding: 0 0.25rem;
    }

    .table-container-glass {
        padding: 0.75rem;
        margin: 0.25rem 0;
    }

    /* Make buttons more touch-friendly */
    button {
        min-height: 44px;
        min-width: 44px;
    }

    /* Improve table readability on very small screens */
    table {
        font-size: 0.75rem;
    }

    /* Stack notification container */
    #notification-container {
        top: 4rem;
        right: 0.5rem;
        left: 0.5rem;
    }

    /* Extra small screen table adjustments */
    .table-wrapper th:nth-child(1),
    .table-wrapper td:nth-child(1) {
        width: 30px;
        /* Even smaller S.No column */
    }

    .table-wrapper th:nth-child(2),
    .table-wrapper td:nth-child(2) {
        width: 50px;
        /* Smaller cover column */
    }

    .table-wrapper th:nth-child(4),
    .table-wrapper td:nth-child(4) {
        width: 60px;
        /* Smaller chapter column */
    }

    .table-wrapper th:nth-child(5),
    .table-wrapper td:nth-child(5) {
        width: 90px;
        /* Smaller actions column */
    }

    /* Make action buttons even more compact */
    .table-wrapper .grid.grid-cols-2 button {
        font-size: 9px;
        padding: 1px 2px;
        min-height: 22px;
    }
}

/* Improve focus indicators for better accessibility */
*:focus {
    outline: 2px solid #ef4444;
    outline-offset: 2px;
}

/* Ensure proper contrast for text */
.text-gray-400 {
    color: #9ca3af;
}

/* Improve button hover states for touch devices */
@media (hover: hover) {
    button:hover {
        transform: translateY(-1px);
    }
}

/* Ensure tables don't break layout - remove duplicate */

/* Improve sidebar on very small screens */
@media (max-width: 480px) {
    #sidebar {
        width: 90vw;
        max-width: 280px;
    }
}

/* Ensure proper spacing for mobile */
@media (max-width: 768px) {
    .space-y-4>*+* {
        margin-top: 1rem;
    }

    .space-x-2>*+* {
        margin-left: 0.5rem;
    }
}