/* Modern Library Management System - Professional Design */
:root {
    /* Primary Colors - Elegant Teal & Orange */
    --primary-color: #0d9488;
    --primary-light: #14b8a6;
    --primary-dark: #0f766e;
    --primary-gradient: linear-gradient(135deg, #0d9488 0%, #14b8a6 100%);
    
    /* Secondary Colors */
    --secondary-color: #f97316;
    --secondary-light: #fb923c;
    --secondary-dark: #ea580c;
    
    /* Accent Colors */
    --accent-purple: #8b5cf6;
    --accent-pink: #ec4899;
    --accent-blue: #3b82f6;
    
    /* Status Colors */
    --success-color: #10b981;
    --success-light: #34d399;
    --warning-color: #f59e0b;
    --warning-light: #fbbf24;
    --danger-color: #ef4444;
    --danger-light: #f87171;
    --info-color: #06b6d4;
    --info-light: #22d3ee;
    
    /* Neutral Colors */
    --white: #ffffff;
    --bg-light: #f0fdfa;
    --bg-gray: #f1f5f9;
    --bg-card: #ffffff;
    --text-dark: #0f172a;
    --text-medium: #334155;
    --text-gray: #64748b;
    --text-light: #94a3b8;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    
    /* Shadows - Enhanced */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --shadow-colored: 0 10px 30px -5px rgba(13, 148, 136, 0.3);
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease;
}

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

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
    overflow-x: auto;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-dark);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

/* Animated Background - New Design */
.animated-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: linear-gradient(135deg, #0d9488 0%, #14b8a6 30%, #06b6d4 60%, #f97316 100%);
    background-size: 400% 400%;
    animation: gradientShift 20s ease infinite;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    25% { background-position: 100% 50%; }
    50% { background-position: 100% 100%; }
    75% { background-position: 50% 100%; }
    100% { background-position: 0% 50%; }
}

/* Floating Shapes Animation */
.floating-shapes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.shape {
    position: absolute;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    animation: float 20s infinite;
}

.shape:nth-child(1) {
    width: 80px;
    height: 80px;
    top: 10%;
    left: 10%;
    animation-delay: 0s;
}

.shape:nth-child(2) {
    width: 120px;
    height: 120px;
    top: 60%;
    right: 10%;
    animation-delay: 2s;
}

.shape:nth-child(3) {
    width: 60px;
    height: 60px;
    bottom: 20%;
    left: 50%;
    animation-delay: 4s;
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-30px) rotate(180deg); }
}

/* Card Styles - Enhanced */
.card {
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    transition: var(--transition);
    border: 1px solid var(--border-light);
    position: relative;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-gradient);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
}

.card-gradient {
    background: var(--primary-gradient);
    color: var(--white);
}

/* Glass Effect */
.glass-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-2xl);
}

/* Buttons - Modern Design */
.btn {
    padding: 0.875rem 1.75rem;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn i {
    position: relative;
    z-index: 1;
}

.btn span {
    position: relative;
    z-index: 1;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: var(--white);
    box-shadow: 0 4px 15px rgba(13, 148, 136, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(13, 148, 136, 0.4);
}

.btn-secondary {
    background: var(--white);
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-secondary:hover {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color) 0%, var(--success-light) 100%);
    color: var(--white);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color) 0%, var(--danger-light) 100%);
    color: var(--white);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning-color) 0%, var(--warning-light) 100%);
    color: var(--white);
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

.btn-info {
    background: linear-gradient(135deg, var(--info-color) 0%, var(--info-light) 100%);
    color: var(--white);
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.3);
}

.btn-info:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.4);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

/* Form Elements */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-dark);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--white);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-control::placeholder {
    color: var(--text-light);
}

/* Input with Icon */
.input-icon {
    position: relative;
}

.input-icon i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-gray);
}

.input-icon .form-control {
    padding-left: 3rem;
}

/* Dashboard Layout */
.dashboard-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar - Professional Design */
.sidebar {
    width: 280px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.08);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: var(--transition);
    border-right: 1px solid var(--border-color);
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--primary-light);
    border-radius: 10px;
}

.sidebar-header {
    padding: 2rem 1.5rem;
    background: var(--primary-gradient);
    color: var(--white);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.sidebar-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: pulse 4s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

.sidebar-logo {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    position: relative;
    z-index: 1;
}

.sidebar-menu {
    padding: 1rem 0;
}

.menu-item {
    padding: 0.875rem 1.5rem;
    margin: 0.25rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-medium);
    text-decoration: none;
    transition: var(--transition-fast);
    cursor: pointer;
    border-radius: var(--radius-lg);
    position: relative;
    font-weight: 500;
}

.menu-item:hover {
    background: linear-gradient(90deg, rgba(13, 148, 136, 0.08) 0%, rgba(20, 184, 166, 0.05) 100%);
    color: var(--primary-color);
    transform: translateX(4px);
}

.menu-item.active {
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: var(--white);
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.25);
}

.menu-item.active i {
    animation: bounceIcon 0.5s ease;
}

@keyframes bounceIcon {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.menu-item i {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
    transition: var(--transition-fast);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 2rem;
    background: var(--bg-light);
}

/* Topbar - Enhanced */
.topbar {
    background: var(--white);
    padding: 1.25rem 2rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    border: 1px solid var(--border-light);
    position: relative;
    overflow: hidden;
}

.topbar::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--primary-gradient);
}

.topbar-left h2 {
    font-size: 1.875rem;
    color: var(--text-dark);
    font-weight: 700;
    letter-spacing: -0.5px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.notification-icon {
    position: relative;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-gray);
    transition: var(--transition);
}

.notification-icon:hover {
    color: var(--primary-color);
}

.notification-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(135deg, var(--danger-color) 0%, var(--danger-light) 100%);
    color: var(--white);
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-full);
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
    animation: pulse-badge 2s ease-in-out infinite;
}

@keyframes pulse-badge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-lg);
    transition: var(--transition);
}

.user-profile:hover {
    background: var(--bg-gray);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 600;
}

/* Stats Cards - Modern Design */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--white);
    padding: 1.75rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    transform: translate(40%, -40%);
    opacity: 0.08;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-xl);
}

.stat-card:hover::before {
    transform: translate(30%, -30%) scale(1.2);
    opacity: 0.12;
}

.stat-icon {
    width: 70px;
    height: 70px;
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: var(--white);
    flex-shrink: 0;
    position: relative;
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
}

.stat-icon::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-xl);
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%);
}

.stat-icon.primary { 
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%); 
}
.stat-card:has(.stat-icon.primary)::before { 
    background: var(--primary-color); 
}

.stat-icon.success { 
    background: linear-gradient(135deg, var(--success-color) 0%, var(--success-light) 100%); 
}
.stat-card:has(.stat-icon.success)::before { 
    background: var(--success-color); 
}

.stat-icon.warning { 
    background: linear-gradient(135deg, var(--warning-color) 0%, var(--warning-light) 100%); 
}
.stat-card:has(.stat-icon.warning)::before { 
    background: var(--warning-color); 
}

.stat-icon.danger { 
    background: linear-gradient(135deg, var(--danger-color) 0%, var(--danger-light) 100%); 
}
.stat-card:has(.stat-icon.danger)::before { 
    background: var(--danger-color); 
}

.stat-icon.secondary { 
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--secondary-light) 100%); 
}
.stat-card:has(.stat-icon.secondary)::before { 
    background: var(--secondary-color); 
}

.stat-icon.info { 
    background: linear-gradient(135deg, var(--info-color) 0%, var(--info-light) 100%); 
}
.stat-card:has(.stat-icon.info)::before { 
    background: var(--info-color); 
}

.stat-info h3 {
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: var(--text-dark);
    line-height: 1;
}

.stat-info p {
    color: var(--text-gray);
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.3px;
}

/* Table Styles - Modern */
.table-container {
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.table-header {
    padding: 1.75rem 2rem;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    border-bottom: 2px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-header h3 {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.table-header h3 i {
    color: var(--primary-color);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
}

th {
    padding: 1.125rem 1.5rem;
    text-align: left;
    font-weight: 700;
    color: var(--text-dark);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

td {
    padding: 1.125rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-medium);
    font-size: 0.9375rem;
}

tbody tr {
    transition: var(--transition);
}

tbody tr:hover {
    background: linear-gradient(90deg, rgba(13, 148, 136, 0.03) 0%, rgba(20, 184, 166, 0.02) 100%);
    transform: scale(1.001);
}

/* Badges - Modern */
.badge {
    padding: 0.4rem 0.875rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.badge-success {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(52, 211, 153, 0.1) 100%);
    color: var(--success-color);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-warning {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(251, 191, 36, 0.1) 100%);
    color: var(--warning-color);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-danger {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15) 0%, rgba(248, 113, 113, 0.1) 100%);
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-info {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.15) 0%, rgba(34, 211, 238, 0.1) 100%);
    color: var(--info-color);
    border: 1px solid rgba(6, 182, 212, 0.2);
}

.badge-primary {
    background: linear-gradient(135deg, rgba(13, 148, 136, 0.15) 0%, rgba(20, 184, 166, 0.1) 100%);
    color: var(--primary-color);
    border: 1px solid rgba(13, 148, 136, 0.2);
}

/* Search Bar */
.search-box {
    position: relative;
    max-width: 400px;
}

.books-search-form {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) auto;
    gap: 1.5rem;
    align-items: flex-end;
}

.books-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.5rem;
}

@media (max-width: 1199px) {
    .books-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 767px) {
    .books-grid {
        grid-template-columns: 1fr;
    }

    .books-search-form {
        grid-template-columns: 1fr;
    }
}

.search-box input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 3rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition: var(--transition);
}

.search-box input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-gray);
}

/* Alerts */
.alert {
    padding: 1rem 1.5rem;
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
    border-left: 4px solid var(--success-color);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border-left: 4px solid var(--danger-color);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
    border-left: 4px solid var(--warning-color);
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info-color);
    border-left: 4px solid var(--info-color);
}

/* Modal - Enhanced with highest z-index */
.modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.5) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    opacity: 0;
    visibility: hidden;
    z-index: 999999 !important;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1 !important;
    visibility: visible !important;
}

.modal {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) scale(0.9) !important;
    background: var(--white) !important;
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-2xl);
    width: 90% !important;
    max-width: 600px !important;
    max-height: 90vh !important;
    overflow-y: auto;
    z-index: 9999999 !important;
    transition: all 0.3s ease;
    display: none;
    opacity: 0;
}

.modal.active,
.modal[style*="display: block"],
.modal[style*="display:block"] {
    display: block !important;
    opacity: 1 !important;
    transform: translate(-50%, -50%) scale(1) !important;
    z-index: 9999999 !important;
}

.modal-overlay.active .modal {
    transform: translate(-50%, -50%) scale(1) !important;
}

/* Specific modal IDs */
#bookModal,
#imageUploadModal {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 99999 !important;
    display: none !important;
    pointer-events: auto !important;
}

#bookModal.active,
#imageUploadModal.active,
#bookModal[style*="display: block"],
#imageUploadModal[style*="display: block"] {
    display: block !important;
    opacity: 1 !important;
    transform: translate(-50%, -50%) scale(1) !important;
    pointer-events: auto !important;
}

/* Ensure modal content is interactive */
.modal .modal-content {
    pointer-events: auto !important;
    position: relative !important;
    z-index: 100000 !important;
}

/* Ensure form elements in modals are editable */
.modal input,
.modal textarea,
.modal select,
.modal button {
    pointer-events: auto !important;
    z-index: 100001 !important;
    position: relative !important;
}

/* Specific fix for inventory modal */
#stockLevelsModal input,
#stockLevelsModal select,
#stockLevelsModal button,
#stockLevelsModal .form-control,
#stockLevelsModal label,
#stockLevelsModal .form-group {
    pointer-events: auto !important;
    z-index: 100002 !important;
    position: relative !important;
    background: white !important;
}

#stockLevelsModal .modal-content {
    pointer-events: auto !important;
    z-index: 100001 !important;
    position: relative !important;
}

/* Prevent modal backdrop from interfering */
#stockLevelsModal .modal-body,
#stockLevelsModal .modal-header {
    pointer-events: auto !important;
    position: relative !important;
    z-index: 100003 !important;
}

/* Ensure all interactive elements work */
#stockLevelsModal * {
    pointer-events: auto !important;
}

/* Modal input focus effects */
#stockLevelsModal input:focus {
    border-color: #2563eb !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1) !important;
    outline: none !important;
}

/* Modal button hover effects - simple to prevent bubbling */
#stockLevelsModal button:hover {
    opacity: 0.9 !important;
}

#stockLevelsModal .close:hover {
    opacity: 1 !important;
}

/* Simple button fixes - matching student modal style */
#stockLevelsModal button[type="submit"],
#stockLevelsModal button[type="button"] {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    z-index: 100001 !important;
    position: relative !important;
}

/* Force sidebar to be below modals */
.sidebar {
    z-index: 998 !important;
}

/* Modal backdrop */
.modal::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
    display: none;
    pointer-events: none;
}

.modal[style*="display: block"]::before {
    display: block;
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 2rem;
}

.modal-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

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

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--primary-color);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
}

.mobile-menu-toggle:hover {
    background: var(--bg-light);
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

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

/* Large Desktop (1200px+) */
@media (min-width: 1200px) {
    .main-content {
        padding: 2rem 3rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 2rem;
    }
    
    .table-container {
        font-size: 0.95rem;
    }
}

/* Desktop (992px - 1199px) */
@media (max-width: 1199px) {
    .sidebar {
        width: 240px;
    }
    
    .main-content {
        margin-left: 240px;
        padding: 1.5rem 2rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 1.5rem;
    }
}

/* Tablet (768px - 991px) */
@media (max-width: 991px) {
    .sidebar {
        width: 260px;
        transform: translateX(-100%);
        z-index: 999;
        position: fixed;
        transition: transform 0.3s ease;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding: 1rem 1.5rem;
        width: 100%;
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    .sidebar-overlay {
        display: block;
    }
    
    .topbar {
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .topbar-left h2 {
        font-size: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-card h3 {
        font-size: 1.5rem;
    }
    
    /* Table responsive: scrolling handled by .table-responsive wrapper via JS */
    .table-container {
        overflow-x: visible;
    }
        
    table {
        min-width: 600px;
        font-size: 0.85rem;
    }
    
    th, td {
        padding: 0.75rem 0.5rem;
    }
    
    /* Form responsive */
    .form-group label {
        font-size: 0.9rem;
    }
    
    .form-control {
        font-size: 0.9rem;
    }
    
    /* Modal responsive */
    .modal {
        width: 95%;
        margin: 1rem;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }
}

/* Mobile Large (576px - 767px) */
@media (max-width: 767px) {
    .main-content {
        padding: 1rem;
    }
    
    .topbar {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        padding: 1rem;
    }
    
    .topbar-left h2 {
        font-size: 1.25rem;
        text-align: center;
    }
    
    .topbar-right {
        justify-content: center;
    }
    
    .user-profile {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1.5rem 1rem;
        text-align: center;
    }
    
    .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 1.25rem;
    }
    
    /* Card responsive */
    .card {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .card h3 {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }
    
    /* Button responsive */
    .btn {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    
    .btn-sm {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
    
    /* Table very responsive */
    table {
        min-width: 500px;
        font-size: 0.8rem;
    }
    
    th, td {
        padding: 0.5rem 0.25rem;
    }
    
    /* Hide less important columns on mobile */
    .hide-mobile {
        display: none;
    }
    
    /* Stack form elements */
    form[style*="grid-template-columns"] {
        display: block !important;
    }
    
    form[style*="grid-template-columns"] > * {
        margin-bottom: 1rem;
    }
    
    /* Alert responsive */
    .alert {
        padding: 1rem;
        font-size: 0.9rem;
    }
    
    /* Badge responsive */
    .badge {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }
}

/* Mobile Small (max 575px) */
@media (max-width: 575px) {
    .main-content {
        padding: 0.75rem;
    }
    
    .sidebar {
        width: 280px;
    }
    
    .topbar-left h2 {
        font-size: 1.1rem;
    }
    
    .stat-card {
        padding: 1rem 0.75rem;
    }
    
    .stat-card h3 {
        font-size: 1.25rem;
    }
    
    .stat-card p {
        font-size: 0.8rem;
    }
    
    .card {
        padding: 0.75rem;
    }
    
    .card h3 {
        font-size: 1.1rem;
    }
    
    /* Very compact table */
    table {
        min-width: 400px;
        font-size: 0.75rem;
    }
    
    th, td {
        padding: 0.4rem 0.2rem;
    }
    
    /* Compact buttons */
    .btn {
        padding: 0.6rem 0.8rem;
        font-size: 0.8rem;
    }
    
    .btn-sm {
        padding: 0.4rem 0.6rem;
        font-size: 0.7rem;
    }
    
    /* Modal full screen on very small devices */
    .modal {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }
    
    /* Form controls smaller */
    .form-control {
        padding: 0.6rem;
        font-size: 0.85rem;
    }
    
    /* Sidebar menu smaller */
    .sidebar-menu .menu-item {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    
    .sidebar-menu .menu-item i {
        font-size: 1rem;
        width: 1.25rem;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .topbar,
    .mobile-menu-toggle,
    .btn,
    .alert {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    
    .card {
        border: 1px solid #ddd !important;
        box-shadow: none !important;
        break-inside: avoid;
    }
    
    table {
        border-collapse: collapse !important;
    }
    
    th, td {
        border: 1px solid #ddd !important;
    }
}

/* High DPI / Retina Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .stat-icon,
    .user-avatar,
    .sidebar-logo {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 767px) and (orientation: landscape) {
    .topbar {
        flex-direction: row;
        padding: 0.75rem 1rem;
    }
    
    .topbar-left h2 {
        font-size: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .main-content {
        padding: 0.75rem;
    }
}

/* Dark mode support (if needed) */
@media (prefers-color-scheme: dark) {
    /* Add dark mode styles here if needed */
}

/* Loading Spinner */
.spinner {
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

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

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.w-full { width: 100%; }

/* Responsive Utilities */
.responsive-form {
    transition: var(--transition);
}

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

.touch-friendly {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
}

.responsive-ready .sidebar {
    transition: transform 0.3s ease;
}

.responsive-ready .main-content {
    transition: margin-left 0.3s ease, padding 0.3s ease;
}

/* Responsive Grid System */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -0.5rem;
}

.col {
    flex: 1;
    padding: 0 0.5rem;
}

.col-12 { flex: 0 0 100%; max-width: 100%; }
.col-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
.col-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
.col-9 { flex: 0 0 75%; max-width: 75%; }
.col-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
.col-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
.col-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
.col-3 { flex: 0 0 25%; max-width: 25%; }
.col-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
.col-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }

@media (max-width: 767px) {
    .col-sm-12 { flex: 0 0 100%; max-width: 100%; }
    .col-sm-6 { flex: 0 0 50%; max-width: 50%; }
    .col-sm-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
    .col-sm-3 { flex: 0 0 25%; max-width: 25%; }
}

/* Responsive Text */
@media (max-width: 767px) {
    .text-sm-center { text-align: center; }
    .text-sm-left { text-align: left; }
    .text-sm-right { text-align: right; }
}

/* Responsive Display */
.d-none { display: none; }
.d-block { display: block; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.d-flex { display: flex; }

@media (max-width: 991px) {
    .d-md-none { display: none; }
    .d-md-block { display: block; }
    .d-md-flex { display: flex; }
}

@media (max-width: 767px) {
    .d-sm-none { display: none; }
    .d-sm-block { display: block; }
    .d-sm-flex { display: flex; }
}

@media (max-width: 575px) {
    .d-xs-none { display: none; }
    .d-xs-block { display: block; }
    .d-xs-flex { display: flex; }
}
