/* ============================================
   SNAM LIBRARY MANAGEMENT SYSTEM - MAIN STYLES
   Responsive Design for Mobile, Tablet, Laptop, PC
   ============================================ */

/* ============================================
   GLOBAL STYLES
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --dark-color: #212529;
    --light-color: #f8f9fa;
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 70px;
    --header-height: 56px;
    --border-radius: 10px;
    --transition-speed: 0.3s;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f0f2f5;
    overflow-x: hidden;
    font-size: 16px;
    line-height: 1.5;
    width: 100%;
    max-width: 100%;
}

html {
    max-width: 100%;
    overflow-x: hidden;
}

.container-fluid,
.row,
main {
    min-width: 0;
    max-width: 100%;
}

.container-fluid {
    overflow-x: clip;
}

.container-fluid > .row {
    display: block;
    width: 100%;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    margin-bottom: 1rem;
}

h1 {
    font-size: 2rem;
}

h2 {
    font-size: 1.75rem;
}

h3 {
    font-size: 1.5rem;
}

h4 {
    font-size: 1.25rem;
}

h5 {
    font-size: 1.1rem;
}

h6 {
    font-size: 1rem;
}

.text-primary { color: var(--primary-color); }
.text-success { color: var(--success-color); }
.text-danger { color: var(--danger-color); }
.text-warning { color: var(--warning-color); }
.text-info { color: var(--info-color); }
.text-muted { color: var(--secondary-color); }

/* ============================================
   SIDEBAR STYLES
   ============================================ */

.sidebar {
    position: fixed;
    top: var(--header-height);
    bottom: 0;
    left: 0;
    z-index: 100;
    padding: 0;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    background-color: var(--dark-color);
    width: var(--sidebar-width);
    transition: transform var(--transition-speed) ease;
    transform: translateX(0);
}

body.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
}

.sidebar .nav-link {
    font-weight: 500;
    padding: 12px 20px;
    margin: 2px 0;
    border-radius: 0;
    transition: all var(--transition-speed);
    color: rgba(255, 255, 255, 0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    padding-left: 25px;
    color: white;
}

.sidebar .nav-link.active {
    background-color: var(--primary-color);
    color: white;
}

.sidebar .nav-link i {
    margin-right: 12px;
    width: 20px;
    text-align: center;
}

.sidebar .nav-link.text-danger:hover {
    background-color: rgba(220, 53, 69, 0.2);
}

/* Sidebar collapsed state for desktop */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .nav-link span {
    display: none;
}

.sidebar.collapsed .nav-link i {
    margin-right: 0;
    font-size: 1.2rem;
}

/* ============================================
   MAIN CONTENT
   ============================================ */

main {
    padding-top: 20px;
    padding-bottom: 50px;
    min-height: 100vh;
    transition: margin-left var(--transition-speed) ease, width var(--transition-speed) ease;
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    overflow-x: hidden;
}

body.sidebar-collapsed main {
    margin-left: 0;
    width: 100%;
}

.sidebar-toggle {
    flex: 0 0 auto;
    width: 42px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.min-width-0 {
    min-width: 0;
}

.navbar-brand {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================
   NAVBAR STYLES
   ============================================ */

.navbar {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    width: 100%;
    min-height: var(--header-height);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 1030;
}

body > .navbar + .container-fluid {
    padding-top: var(--header-height);
}

.navbar-brand {
    font-weight: bold;
    font-size: 1.25rem;
}

.navbar-brand i {
    margin-right: 8px;
}

/* ============================================
   CARDS
   ============================================ */

.card {
    border-radius: var(--border-radius);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 20px;
    border: none;
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.card-header {
    background-color: var(--light-color);
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
    padding: 15px 20px;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.card-header.bg-primary,
.card-header.bg-success,
.card-header.bg-danger,
.card-header.bg-warning,
.card-header.bg-info {
    color: white;
}

.card-body {
    padding: 20px;
}

.card-footer {
    background-color: var(--light-color);
    border-top: 1px solid #dee2e6;
    padding: 15px 20px;
}

/* Stat Cards */
.card.text-white .card-body {
    padding: 20px;
}

.card.text-white h2, 
.card.text-white h3,
.card.text-white h4 {
    margin-bottom: 5px;
    font-size: 2rem;
}

/* ============================================
   TABLES
   ============================================ */

.table-responsive {
    width: 100%;
    max-width: 100%;
    overflow: visible;
}

.table {
    margin-bottom: 0;
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    word-break: normal;
}

.table th {
    font-weight: 600;
    background-color: var(--light-color);
    border-bottom: 2px solid #dee2e6;
    padding: 12px;
    vertical-align: middle;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.table td {
    padding: 12px;
    vertical-align: middle;
    border-bottom: 1px solid #dee2e6;
    min-width: 0;
    max-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.table td a,
.table td button,
.table td .btn,
.table th a,
.table th button {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
}

.table .badge {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
}

.table td .btn-group {
    display: flex;
    flex-wrap: wrap;
    max-width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
    gap: 4px;
}

.table td .btn-group .btn {
    margin: 0;
    min-width: 0;
    max-width: 100%;
    padding-left: 2px;
    padding-right: 2px;
    overflow-wrap: anywhere;
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.02);
}

.table-hover tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.05);
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    border-radius: 8px;
    padding: 8px 16px;
    font-weight: 500;
    transition: all var(--transition-speed);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 1.1rem;
}

.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-success {
    background-color: var(--success-color);
    border-color: var(--success-color);
}

.btn-danger {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
}

.btn-warning {
    background-color: var(--warning-color);
    border-color: var(--warning-color);
    color: #000;
}

.btn-info {
    background-color: var(--info-color);
    border-color: var(--info-color);
    color: #000;
}

.btn-outline-primary:hover,
.btn-outline-success:hover,
.btn-outline-danger:hover {
    transform: translateY(-1px);
}

.btn-group .btn {
    margin: 0 2px;
}

/* ============================================
   FORMS
   ============================================ */

.form-control,
.form-select {
    border-radius: 8px;
    border: 1px solid #ced4da;
    padding: 10px 12px;
    transition: all var(--transition-speed);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
    outline: none;
}

.form-control.is-invalid,
.form-select.is-invalid {
    border-color: var(--danger-color);
}

.form-label {
    font-weight: 500;
    margin-bottom: 8px;
}

.form-text {
    font-size: 0.8rem;
    color: var(--secondary-color);
}
/* KPI Update Animation */
@keyframes kpiPulse {
    0% {
        transform: scale(1);
        background-color: inherit;
    }
    50% {
        transform: scale(1.05);
        background-color: rgba(13, 110, 253, 0.3);
    }
    100% {
        transform: scale(1);
        background-color: inherit;
    }
}

.kpi-updated {
    animation: kpiPulse 0.5s ease;
}

/* Sort Links */
.sort-link {
    color: #333;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.sort-link:hover {
    color: #0d6efd;
}

.sort-link i {
    font-size: 12px;
}

/* Loading States */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0d6efd;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Lazy Loading Images */
img[data-src] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

img[data-src].loaded {
    opacity: 1;
}

/* ============================================
   ALERTS
   ============================================ */

.alert {
    border-radius: 8px;
    padding: 12px 20px;
    margin-bottom: 20px;
    animation: slideDown 0.5s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert-dismissible .btn-close {
    padding: 12px;
}

/* ============================================
   MODALS
   ============================================ */

.modal-content {
    border-radius: 12px;
    border: none;
}

.modal-header {
    background-color: var(--primary-color);
    color: white;
    border-radius: 12px 12px 0 0;
    padding: 15px 20px;
}

.modal-header .btn-close {
    filter: brightness(0) invert(1);
}

.modal-title {
    font-weight: 600;
}

.modal-body {
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-footer {
    border-top: 1px solid #dee2e6;
    padding: 15px 20px;
}

/* ============================================
   BADGES
   ============================================ */

.badge {
    font-size: 0.75rem;
    padding: 5px 10px;
    border-radius: 20px;
    font-weight: 500;
}

.badge.bg-success { background-color: var(--success-color); }
.badge.bg-danger { background-color: var(--danger-color); }
.badge.bg-warning { background-color: var(--warning-color); color: #000; }
.badge.bg-info { background-color: var(--info-color); color: #000; }
.badge.bg-primary { background-color: var(--primary-color); }
.badge.bg-secondary { background-color: var(--secondary-color); }

/* ============================================
   PAGINATION
   ============================================ */

.pagination {
    margin-top: 20px;
}

.page-link {
    border-radius: 8px;
    margin: 0 3px;
    color: var(--primary-color);
}

.page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.page-link:hover {
    background-color: var(--light-color);
    transform: translateY(-1px);
}

/* ============================================
   CHARTS
   ============================================ */

canvas {
    max-width: 100%;
    height: auto;
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* ============================================
   MOBILE TOGGLE BUTTON
   ============================================ */

.mobile-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1001;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 24px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: all var(--transition-speed);
}

.mobile-toggle:hover {
    transform: scale(1.05);
    background-color: #0b5ed7;
}

/* ============================================
   LOADING SPINNER
   ============================================ */

.spinner-border {
    width: 3rem;
    height: 3rem;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1050;
}

.toast {
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* ============================================
   FOOTER
   ============================================ */

footer {
    margin-top: 50px;
    padding: 20px;
    text-align: center;
    background-color: var(--light-color);
    border-top: 1px solid #dee2e6;
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Large Desktop (1200px and above) */
@media (min-width: 1200px) {
    .container-fluid {
        padding: 0 30px;
    }
    
    .sidebar {
        width: var(--sidebar-width);
    }
    
    main {
        margin-left: var(--sidebar-width);
    }
}

/* Desktop (992px to 1199px) */
@media (min-width: 992px) and (max-width: 1199px) {
    .sidebar {
        width: var(--sidebar-width);
    }
    
    main {
        margin-left: var(--sidebar-width);
    }
    
    .card-body {
        padding: 15px;
    }
}

/* Tablet (768px to 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    .sidebar {
        width: 220px;
    }
    
    .sidebar .nav-link {
        padding: 10px 15px;
        font-size: 14px;
    }
    
    main {
        margin-left: 220px;
        width: calc(100% - 220px);
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    .card-body {
        padding: 15px;
    }
    
    .table td, .table th {
        padding: 8px;
        font-size: 13px;
    }
}

/* Mobile Landscape (576px to 767px) */
@media (min-width: 576px) and (max-width: 767px) {
    .sidebar {
        position: fixed;
        top: var(--header-height);
        left: -100%;
        width: 280px;
        height: calc(100% - var(--header-height));
        transition: left var(--transition-speed) ease;
        z-index: 1000;
    }
    
    .sidebar.show {
        left: 0;
    }

    .sidebar.is-open {
        display: block;
        left: 0;
        transform: translateX(0);
    }
    
    main {
        margin-left: 0;
        width: 100%;
        padding: 10px;
    }
    
    .mobile-toggle {
        display: block;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.3rem;
    }
    
    .card-header {
        padding: 12px 15px;
    }
    
    .card-body {
        padding: 12px;
    }
    
    .table td, .table th {
        padding: 8px;
        font-size: 12px;
    }
    
    .btn {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .btn-sm {
        padding: 3px 8px;
        font-size: 11px;
    }
    
    .modal-dialog {
        margin: 10px;
    }
    
    .row > [class*="col-"] {
        margin-bottom: 15px;
    }
}

/* Mobile Portrait (up to 575px) */
@media (max-width: 575px) {
    body > .navbar + .container-fluid {
        padding-top: 84px;
    }

    .sidebar {
        position: fixed;
        top: var(--header-height);
        left: -100%;
        width: 85%;
        height: calc(100% - var(--header-height));
        transition: left var(--transition-speed) ease;
        z-index: 1000;
    }
    
    .sidebar.show {
        left: 0;
    }

    .sidebar.is-open {
        display: block;
        left: 0;
        transform: translateX(0);
    }
    
    main {
        margin-left: 0;
        width: 100%;
        padding: 8px;
    }
    
    .mobile-toggle {
        display: block;
        width: 45px;
        height: 45px;
        font-size: 20px;
        bottom: 15px;
        right: 15px;
    }
    
    h1 {
        font-size: 1.3rem;
        margin-bottom: 0.75rem;
    }
    
    h2 {
        font-size: 1.1rem;
    }
    
    h3 {
        font-size: 1rem;
    }
    
    .card-header {
        padding: 10px 12px;
    }
    
    .card-header h5, 
    .card-header h6 {
        font-size: 0.9rem;
    }
    
    .card-body {
        padding: 10px;
    }
    
    .table td, .table th {
        padding: 6px;
        font-size: 11px;
    }
    
    .btn {
        padding: 5px 10px;
        font-size: 12px;
    }
    
    .btn-sm {
        padding: 3px 6px;
        font-size: 10px;
    }
    
    .btn-group {
        flex-wrap: wrap;
    }
    
    .btn-group .btn {
        margin: 2px;
    }
    
    .form-control,
    .form-select {
        padding: 8px 10px;
        font-size: 14px;
    }
    
    .form-label {
        font-size: 13px;
        margin-bottom: 5px;
    }
    
    .modal-body {
        padding: 12px;
    }
    
    .alert {
        padding: 10px 15px;
        font-size: 13px;
    }
    
    .badge {
        font-size: 10px;
        padding: 3px 6px;
    }
    
    .navbar-brand {
        font-size: 1rem;
    }
    
    .row {
        margin: 0;
    }
    
    .col-12, .col-md-3, .col-md-4, .col-md-6 {
        padding: 0 8px;
    }
    
    /* Stack buttons vertically on mobile */
    .d-flex.justify-content-between {
        flex-direction: column;
        gap: 10px;
    }
    
    .d-flex.justify-content-between .btn-group,
    .d-flex.justify-content-between div:last-child {
        width: 100%;
    }
    
    .d-flex.justify-content-between .btn {
        width: 100%;
        margin: 2px 0;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .sidebar,
    .navbar,
    .mobile-toggle,
    .btn,
    .btn-group,
    .modal,
    .no-print {
        display: none !important;
    }
    
    main {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .table {
        border: 1px solid #ddd;
    }
    
    body {
        background-color: white;
        font-size: 12pt;
    }
    
    a {
        text-decoration: none;
        color: black;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.cursor-pointer {
    cursor: pointer;
}

.text-ellipsis {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.shadow-sm {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.shadow-md {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.shadow-lg {
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
}

.rounded-lg {
    border-radius: 12px;
}

.rounded-xl {
    border-radius: 16px;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

.slide-up {
    animation: slideUp 0.5s ease;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Focus visible for accessibility */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    body.dark-mode {
        background-color: #1a1a2e;
        color: #eee;
    }
    
    body.dark-mode .card,
    body.dark-mode .modal-content {
        background-color: #16213e;
        color: #eee;
    }
    
    body.dark-mode .table {
        color: #eee;
    }
    
    body.dark-mode .form-control,
    body.dark-mode .form-select {
        background-color: #0f3460;
        border-color: #1a1a2e;
        color: #eee;
    }
}