/* ===================================================
   GLOBAL RESPONSIVE CSS - Library Management System
   All Pages Mobile-First Design
   =================================================== */

/* ===== BASE RESET ===== */
* {
    -webkit-tap-highlight-color: transparent;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
    position: relative;
    width: 100%;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ===== SIDEBAR RESPONSIVE ===== */
@media (max-width: 991px) {
    .sidebar,
    .sidebar-custom {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 9999;
    }
    
    .sidebar.active,
    .sidebar-custom.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 15px !important;
    }
    
    /* Mobile Menu Toggle Button */
    .mobile-menu-toggle {
        display: flex !important;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 10000;
        width: 45px;
        height: 45px;
        border-radius: 12px;
        background: linear-gradient(135deg, #667eea, #764ba2);
        color: white;
        border: none;
        align-items: center;
        justify-content: center;
        font-size: 20px;
        box-shadow: 0 5px 20px rgba(102,126,234,0.4);
    }
    
    /* Overlay when sidebar open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 9998;
        backdrop-filter: blur(3px);
    }
    
    .sidebar-overlay.active {
        display: block;
    }
}

@media (min-width: 992px) {
    .mobile-menu-toggle {
        display: none !important;
    }
}

/* ===== TABLES RESPONSIVE ===== */
@media (max-width: 767px) {
    .table-responsive {
        border: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table-responsive table {
        min-width: 600px;
    }
    
    /* Table cell padding adjust */
    .table th,
    .table td {
        padding: 10px 8px !important;
        font-size: 13px !important;
    }
    
    /* Hide less important columns on mobile */
    .hide-mobile {
        display: none !important;
    }
}

/* ===== STAT CARDS RESPONSIVE ===== */
@media (max-width: 767px) {
    .stat-card {
        padding: 18px !important;
        margin-bottom: 12px !important;
    }
    
    .stat-card h2,
    .stat-card h4 {
        font-size: 26px !important;
    }
    
    .stat-card p {
        font-size: 12px !important;
    }
    
    .stat-card i {
        font-size: 24px !important;
        top: 10px !important;
        left: 10px !important;
    }
}

/* ===== ID CARD RESPONSIVE ===== */
@media (max-width: 900px) {
    .cards-container {
        flex-direction: column !important;
        align-items: center !important;
        gap: 20px !important;
    }
    
    .id-card {
        width: 340px !important;
        height: 520px !important;
        transform: scale(1);
    }
}

@media (max-width: 420px) {
    .id-card {
        width: 300px !important;
        height: 460px !important;
    }
    
    .id-card .student-name {
        font-size: 16px !important;
    }
    
    .id-card .photo-wrapper img {
        width: 90px !important;
        height: 90px !important;
    }
}

/* ===== FORMS RESPONSIVE ===== */
@media (max-width: 767px) {
    .form-control,
    .form-select {
        font-size: 16px !important; /* Prevent zoom on iOS */
        padding: 12px 14px !important;
    }
    
    .input-group-text {
        font-size: 14px !important;
    }
    
    .btn {
        font-size: 14px !important;
        padding: 10px 18px !important;
    }
    
    .btn-sm {
        padding: 7px 12px !important;
        font-size: 12px !important;
    }
    
    /* Stack form buttons */
    .form-buttons {
        flex-direction: column !important;
    }
    
    .form-buttons .btn {
        width: 100% !important;
        margin-bottom: 10px !important;
    }
}

/* ===== MODALS RESPONSIVE ===== */
@media (max-width: 767px) {
    .modal-dialog {
        margin: 10px !important;
        max-width: calc(100% - 20px) !important;
    }
    
    .modal-content {
        border-radius: 15px !important;
    }
    
    .modal-body {
        padding: 15px !important;
        max-height: 70vh;
        overflow-y: auto;
    }
}

/* ===== HEADER RESPONSIVE ===== */
@media (max-width: 767px) {
    .header,
    .top-header,
    .page-header {
        padding: 15px !important;
        flex-direction: column !important;
        gap: 12px !important;
        text-align: center;
    }
    
    .header h2,
    .top-header h3,
    .page-header h2 {
        font-size: 18px !important;
    }
    
    .header .user-info span {
        font-size: 13px;
    }
    
    .header .user-info img {
        width: 35px !important;
        height: 35px !important;
    }
}

/* ===== BOOK CARDS RESPONSIVE ===== */
@media (max-width: 767px) {
    .book-card {
        padding: 15px !important;
        margin-bottom: 15px !important;
    }
    
    .book-card img {
        height: 180px !important;
    }
    
    .book-card h6 {
        font-size: 14px !important;
    }
    
    .book-card .author {
        font-size: 12px !important;
    }
}

/* ===== LOGIN PAGE RESPONSIVE ===== */
@media (max-width: 900px) {
    .login-container {
        max-width: 450px !important;
        margin: 20px auto !important;
    }
    
    .side-image,
    .left-section {
        display: none !important;
    }
    
    .login-box,
    .right-section {
        width: 100% !important;
        padding: 35px 25px !important;
        margin: 0 !important;
    }
}

/* ===== PAYMENT CARDS RESPONSIVE ===== */
@media (max-width: 767px) {
    .payment-card {
        min-height: 80px !important;
        padding: 12px 8px !important;
    }
    
    .payment-card .payment-icon-wrapper {
        width: 42px !important;
        height: 42px !important;
        padding: 6px !important;
    }
    
    .payment-card .payment-name {
        font-size: 10px !important;
    }
}

/* ===== DASHBOARD GRID RESPONSIVE ===== */
@media (max-width: 991px) {
    .col-md-3,
    .col-md-4,
    .col-md-6,
    .col-md-8,
    .col-lg-3,
    .col-lg-4,
    .col-lg-5,
    .col-lg-6,
    .col-lg-7,
    .col-lg-8 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    .col-md-3 {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }
    .col-md-4 {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }
    .col-md-6 {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }
}

/* ===== HIDE ON MOBILE ===== */
@media (max-width: 767px) {
    .hide-on-mobile {
        display: none !important;
    }
    
    .show-on-mobile {
        display: block !important;
    }
}

@media (min-width: 768px) {
    .show-on-mobile {
        display: none !important;
    }
}

/* ===== TEXT SIZES RESPONSIVE ===== */
@media (max-width: 767px) {
    h1, .h1 { font-size: 22px !important; }
    h2, .h2 { font-size: 20px !important; }
    h3, .h3 { font-size: 18px !important; }
    h4, .h4 { font-size: 16px !important; }
    h5, .h5 { font-size: 15px !important; }
    h6, .h6 { font-size: 14px !important; }
    
    p, .small { font-size: 13px !important; }
}

/* ===== SPACING RESPONSIVE ===== */
@media (max-width: 767px) {
    .container,
    .container-fluid {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
    
    .mb-4 { margin-bottom: 15px !important; }
    .mb-5 { margin-bottom: 20px !important; }
    .py-4 { padding-top: 15px !important; padding-bottom: 15px !important; }
    .py-5 { padding-top: 20px !important; padding-bottom: 20px !important; }
    
    .row {
        margin-left: -8px !important;
        margin-right: -8px !important;
    }
    
    [class*="col-"] {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }
}

/* ===== MOBILE SIDEBAR HAMBURGER ===== */
.mobile-menu-toggle {
    display: none;
}

/* ===== SAFE AREA (iPhone notch) ===== */
@supports(padding: max(0px)) {
    body {
        padding-left: min(0vmin, env(safe-area-inset-left));
        padding-right: min(0vmin, env(safe-area-inset-right));
    }
}

/* ===== SMOOTH SCROLL ===== */
html {
    scroll-behavior: smooth;
}

/* ===== SCROLLBAR STYLING ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ===== PRINT ===== */
@media print {
    .mobile-menu-toggle,
    .sidebar,
    .sidebar-custom,
    .no-print {
        display: none !important;
    }
    
    .main-content,
    .content-wrapper {
        margin-left: 0 !important;
        padding: 0 !important;
    }
}