/* Custom CSS for Library Management Dashboard */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f8fafc;
    color: #1f2937;
    line-height: 1.6;
}

/* Sidebar Navigation Styles */
.nav-item {
    color: #6b7280;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.nav-item:hover {
    color: #374151;
    background-color: #f9fafb;
    transform: translateX(2px);
}

.nav-item.active {
    color: #059669;
    background-color: #ecfdf5;
    border: 1px solid #d1fae5;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(to bottom, #10b981, #059669);
    border-radius: 0 2px 2px 0;
}

/* Sidebar - Default visible on desktop */
.fixed.left-0 {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Stat Cards Animation */
.stat-card {
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(229, 231, 235, 0.8);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #10b981, transparent);
    transition: left 0.5s ease;
}

.stat-card:hover::before {
    left: 100%;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border-color: rgba(16, 185, 129, 0.2);
}

/* Book Cards Animation */
.book-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
}

.book-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #e5e7eb;
}

/* Tab Buttons */
.tab-btn {
    color: #6b7280;
    background: transparent;
    border: none;
    cursor: pointer;
}

.tab-btn.active {
    color: #059669;
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.tab-btn:hover:not(.active) {
    color: #374151;
    background: rgba(255, 255, 255, 0.5);
}

/* Table Hover Effects */
tbody tr {
    transition: all 0.2s ease;
}

tbody tr:hover {
    background-color: #f9fafb;
    transform: scale(1.001);
}

/* Search Input Focus Effect */
input[type="text"]:focus {
    background-color: white;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Button Hover Effects */
button {
    transition: all 0.2s ease;
}

button:hover {
    transform: translateY(-1px);
}

/* Notification Badge Pulse */
.relative .absolute {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Glassmorphism Effects */
.bg-white {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Smooth Page Transitions */
main {
    animation: fadeIn 0.5s ease-in-out;
}

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

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ============================================
   MOBILE MENU STYLES
   ============================================ */

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
}

/* Ensure sidebar is visible on desktop */
@media (min-width: 1025px) {
    .fixed.left-0 {
        transform: translateX(0) !important;
    }
}

@media (max-width: 1024px) {
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 2.75rem;
        height: 2.75rem;
        border: 1px solid #e5e7eb;
    }
    
    .mobile-menu-btn:hover {
        background-color: #f9fafb;
        transform: scale(1.05);
    }
    
    .mobile-menu-btn:active {
        transform: scale(0.95);
    }
}

/* Mobile Menu Overlay */
.mobile-menu-overlay {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.mobile-menu-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.mobile-menu-overlay.hidden {
    display: none;
}

/* ============================================
   RESPONSIVE DESIGN - MEDIA QUERIES
   ============================================ */

/* Extra Large Screens (1440px and above) */
@media (min-width: 1440px) {
    main {
        max-width: 1400px;
        margin: 0 auto;
    }
    
    .stat-card {
        padding: 2rem;
    }
    
    .text-3xl {
        font-size: 2.5rem;
    }
}

/* Large Screens (1024px - 1439px) */
@media (max-width: 1439px) and (min-width: 1024px) {
    .px-8 {
        padding-left: 2rem;
        padding-right: 2rem;
    }
    
    table {
        font-size: 0.875rem;
    }
}

/* Tablet Landscape & Small Desktop (1024px and below) */
@media (max-width: 1024px) {
    /* Remove sidebar margin from main content */
    .ml-60 {
        margin-left: 0 !important;
    }
    
    /* Hide sidebar by default - IMPORTANT: sidebar must be hidden on mobile */
    .fixed.left-0 {
        transform: translateX(-100%) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
        z-index: 50;
    }
    
    /* Show sidebar ONLY when open class is added */
    .fixed.left-0.open {
        transform: translateX(0) !important;
    }
    
    /* Adjust header for mobile menu button */
    header {
        padding-left: 4rem !important;
    }
    
    /* Stat cards - 2 columns */
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Reduce padding */
    .px-8 {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
    
    .py-8 {
        padding-top: 1.5rem;
        padding-bottom: 1.5rem;
    }
    
    /* Table responsiveness */
    table {
        font-size: 0.813rem;
    }
    
    th, td {
        padding: 0.75rem 0.5rem;
    }
}

/* Tablet Portrait (768px and below) */
@media (max-width: 768px) {
    /* Typography adjustments */
    .text-3xl {
        font-size: 1.875rem;
    }
    
    .text-xl {
        font-size: 1.125rem;
    }
    
    .text-lg {
        font-size: 1rem;
    }
    
    /* Stat cards - 2 columns */
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    /* Stat card adjustments */
    .stat-card {
        padding: 1.25rem;
    }
    
    /* Grid column spans */
    .lg\:col-span-2 {
        grid-column: span 2;
    }
    
    .lg\:col-span-3 {
        grid-column: span 2;
    }
    
    /* Reduce padding */
    .px-8 {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .py-8 {
        padding-top: 1rem;
        padding-bottom: 1rem;
    }
    
    .p-6 {
        padding: 1rem;
    }
    
    /* Header adjustments */
    header .flex {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    /* Search bar full width on wrap */
    header .flex-1.max-w-2xl {
        flex: 1 1 100%;
        max-width: 100%;
    }
    
    /* Hide some header elements */
    header select {
        display: none;
    }
    
    /* Table scroll */
    .overflow-x-auto {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 600px;
    }
    
    /* Book cards */
    .book-card img {
        width: 2.5rem;
        height: 3.5rem;
    }
    
    /* Sidebar adjustments */
    .fixed.left-0 {
        width: 240px;
    }
    
    /* Navigation items */
    .nav-item {
        padding: 0.625rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .nav-item i {
        width: 1.125rem;
        height: 1.125rem;
    }
}

/* Mobile Landscape (640px and below) */
@media (max-width: 640px) {
    /* Single column layout */
    .grid-cols-4,
    .grid-cols-2,
    .grid-cols-1 {
        grid-template-columns: 1fr;
    }
    
    /* Grid column spans reset */
    .lg\:col-span-2,
    .lg\:col-span-3,
    .lg\:col-span-4 {
        grid-column: span 1;
    }
    
    /* Typography */
    .text-3xl {
        font-size: 1.5rem;
    }
    
    .text-2xl {
        font-size: 1.25rem;
    }
    
    .text-xl {
        font-size: 1rem;
    }
    
    /* Stat cards */
    .stat-card {
        padding: 1rem;
    }
    
    /* Spacing adjustments */
    .px-8 {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .py-8 {
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }
    
    .p-6 {
        padding: 0.875rem;
    }
    
    .gap-6 {
        gap: 0.75rem;
    }
    
    .gap-8 {
        gap: 1rem;
    }
    
    /* Header */
    header {
        padding: 0.75rem 1rem !important;
    }
    
    header .flex {
        flex-direction: column;
        align-items: stretch;
    }
    
    header .flex-1.max-w-2xl {
        max-width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* Search input */
    input[type="text"] {
        padding: 0.625rem 0.75rem 0.625rem 2.5rem;
        font-size: 0.875rem;
    }
    
    input[type="text"]::placeholder {
        font-size: 0.813rem;
    }
    
    /* Hide user profile text */
    header .hidden.md\:block {
        display: none !important;
    }
    
    /* Adjust spacing in header right section */
    .space-x-4 > * + * {
        margin-left: 0.5rem;
    }
    
    /* User profile image */
    header img {
        width: 2rem;
        height: 2rem;
    }
    
    /* Buttons */
    button {
        padding: 0.5rem;
        font-size: 0.875rem;
    }
    
    /* Tables */
    table {
        font-size: 0.75rem;
        min-width: 500px;
    }
    
    th, td {
        padding: 0.5rem 0.25rem;
    }
    
    th {
        font-size: 0.688rem;
    }
    
    /* Book cards */
    .book-card {
        padding: 0.625rem;
    }
    
    .book-card img {
        width: 2rem;
        height: 3rem;
    }
    
    .book-card h4 {
        font-size: 0.813rem;
    }
    
    .book-card p {
        font-size: 0.688rem;
    }
    
    /* Sidebar */
    .fixed.left-0 {
        width: 220px;
    }
    
    .fixed.left-0 .text-xl {
        font-size: 1rem;
    }
    
    .fixed.left-0 .w-8.h-8 {
        width: 1.75rem;
        height: 1.75rem;
    }
    
    /* Navigation */
    .nav-item {
        padding: 0.5rem 0.625rem;
        font-size: 0.813rem;
    }
    
    .nav-item i {
        width: 1rem;
        height: 1rem;
        margin-right: 0.5rem;
    }
    
    /* Status badges */
    .status-badge {
        font-size: 0.625rem;
        padding: 0.125rem 0.5rem;
    }
    
    /* Rounded corners adjustment */
    .rounded-2xl {
        border-radius: 1rem;
    }
    
    .rounded-xl {
        border-radius: 0.75rem;
    }
}

/* Small Mobile (480px and below) */
@media (max-width: 480px) {
    /* Further reduce typography */
    .text-3xl {
        font-size: 1.375rem;
    }
    
    .text-lg {
        font-size: 0.938rem;
    }
    
    /* Minimal padding */
    .px-8 {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    .py-8 {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
    
    .p-6 {
        padding: 0.75rem;
    }
    
    /* Stat cards */
    .stat-card {
        padding: 0.875rem;
    }
    
    /* Header */
    header {
        padding: 0.625rem 0.75rem !important;
    }
    
    /* Search */
    input[type="text"] {
        padding: 0.5rem 0.625rem 0.5rem 2.25rem;
        font-size: 0.813rem;
    }
    
    /* Tables */
    table {
        font-size: 0.688rem;
        min-width: 450px;
    }
    
    th, td {
        padding: 0.375rem 0.25rem;
    }
    
    /* Sidebar */
    .fixed.left-0 {
        width: 200px;
    }
    
    /* Logo */
    .fixed.left-0 .px-6 {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Navigation */
    .nav-item {
        padding: 0.5rem;
        font-size: 0.75rem;
    }
    
    /* Gaps */
    .gap-6 {
        gap: 0.5rem;
    }
    
    .gap-8 {
        gap: 0.75rem;
    }
    
    /* Book cards */
    .book-card {
        padding: 0.5rem;
    }
    
    /* Notification button */
    .relative.p-2 {
        padding: 0.375rem;
    }
}

/* Extra Small Mobile (360px and below) */
@media (max-width: 360px) {
    /* Minimal spacing */
    .px-8 {
        padding-left: 0.375rem;
        padding-right: 0.375rem;
    }
    
    .stat-card {
        padding: 0.75rem;
    }
    
    .text-3xl {
        font-size: 1.25rem;
    }
    
    /* Sidebar */
    .fixed.left-0 {
        width: 180px;
    }
    
    /* Tables */
    table {
        font-size: 0.625rem;
        min-width: 400px;
    }
    
    /* Search */
    input[type="text"] {
        font-size: 0.75rem;
    }
}

/* Landscape Orientation Adjustments */
@media (max-height: 600px) and (orientation: landscape) {
    /* Reduce vertical padding */
    .py-8 {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
    
    .stat-card {
        padding: 0.75rem;
    }
    
    /* Compact header */
    header {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }
    
    /* Sidebar adjustments */
    .fixed.left-0 nav {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
    
    .nav-item {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
}

/* Print Styles */
@media print {
    /* Hide navigation and interactive elements */
    .fixed.left-0,
    header button,
    header select,
    header .relative.p-2,
    .nav-item {
        display: none;
    }
    
    /* Remove margins */
    .ml-60 {
        margin-left: 0;
    }
    
    /* Adjust for print */
    body {
        background: white;
    }
    
    .bg-white {
        background: white !important;
        box-shadow: none !important;
    }
    
    /* Expand content */
    main {
        padding: 1rem;
    }
    
    /* Remove animations */
    * {
        animation: none !important;
        transition: none !important;
    }
    
    /* Page breaks */
    .stat-card,
    table {
        page-break-inside: avoid;
    }
}

/* Loading Animation for Charts */
.chart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 128px;
}

.chart-loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #10b981;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-available {
    background-color: #ecfdf5;
    color: #059669;
}

.status-borrowed {
    background-color: #fef3c7;
    color: #d97706;
}

.status-overdue {
    background-color: #fee2e2;
    color: #dc2626;
}

/* Micro-interactions */
.hover-lift {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Focus States */
.focus-ring:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Dark Mode Support (Optional) */
@media (prefers-color-scheme: dark) {
    .dark-mode {
        background-color: #0f172a;
        color: #f1f5f9;
    }
    
    .dark-mode .bg-white {
        background: rgba(30, 41, 59, 0.95);
        border-color: rgba(51, 65, 85, 0.8);
    }
    
    .dark-mode .text-gray-900 {
        color: #f1f5f9;
    }
    
    .dark-mode .text-gray-600 {
        color: #94a3b8;
    }
    
    .dark-mode .border-gray-200 {
        border-color: #334155;
    }
}

/* Page Swipe Transitions */
#page-container {
    min-height: 100vh;
    position: relative;
    overflow: hidden;
}

.page-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 100vh;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.page-content.active {
    transform: translateX(0);
    z-index: 2;
    position: relative;
}

.page-content.slide-out-left {
    transform: translateX(-100%);
    z-index: 1;
}

.page-content.slide-out-right {
    transform: translateX(100%);
    z-index: 1;
}

.page-content.slide-in-left {
    transform: translateX(-100%);
    z-index: 3;
}

.page-content.slide-in-right {
    transform: translateX(100%);
    z-index: 3;
}

/* Loading State */
.page-loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
}

.page-loading::after {
    content: '';
    width: 50px;
    height: 50px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #10b981;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}