/* ========================================
   RESPONSIVE FRAMEWORK - ENTERPRISE GRADE
   Perfect layouts on ALL screen sizes
   ======================================== */

/* ========================================
   RESPONSIVE BREAKPOINTS
   ======================================== */
:root {
    /* Breakpoint Variables */
    --breakpoint-xs: 320px;
    /* Small phones */
    --breakpoint-sm: 480px;
    /* Phones */
    --breakpoint-md: 768px;
    /* Tablets */
    --breakpoint-lg: 1024px;
    /* Laptops */
    --breakpoint-xl: 1280px;
    /* Desktops */
    --breakpoint-xxl: 1536px;
    /* Large desktops */

    /* Responsive Spacing */
    --spacing-mobile: 0.75rem;
    --spacing-tablet: 1rem;
    --spacing-desktop: 1.5rem;

    /* Container Max Widths */
    --container-sm: 640px;
    --container-md: 768px;
    --container-lg: 1024px;
    --container-xl: 1280px;
}

/* ========================================
   RESPONSIVE CONTAINERS
   ======================================== */
.container-fluid {
    width: 100%;
    padding-right: var(--spacing-mobile);
    padding-left: var(--spacing-mobile);
    margin-right: auto;
    margin-left: auto;
}

@media (min-width: 768px) {
    .container-fluid {
        padding-right: var(--spacing-tablet);
        padding-left: var(--spacing-tablet);
    }
}

@media (min-width: 1024px) {
    .container-fluid {
        padding-right: var(--spacing-desktop);
        padding-left: var(--spacing-desktop);
    }
}

/* Responsive Container Sizes */
.container-sm {
    max-width: var(--container-sm);
}

.container-md {
    max-width: var(--container-md);
}

.container-lg {
    max-width: var(--container-lg);
}

.container-xl {
    max-width: var(--container-xl);
}

/* ========================================
   ADMIN PANEL RESPONSIVE LAYOUT
   ======================================== */
.admin-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: 100vh;
    transition: all 0.3s ease;
}

.admin-content {
    padding: clamp(1rem, 3vw, 2rem);
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
}

/* Tablet Layout (768px - 1023px) */
@media (max-width: 1023px) {
    .admin-layout {
        grid-template-columns: 200px 1fr;
    }

    .admin-sidebar {
        padding: 1rem;
    }

    .nav-item {
        font-size: 0.9rem;
        padding: 0.65rem 0.85rem;
    }
}

/* Mobile Layout (< 768px) */
@media (max-width: 767px) {
    .admin-layout {
        grid-template-columns: 1fr;
        position: relative;
    }

    .admin-sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 280px;
        max-width: 85vw;
        height: 100vh;
        z-index: 9999;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        box-shadow: 5px 0 25px rgba(0, 0, 0, 0.5);
        padding: 1.5rem;
    }

    .admin-sidebar.active {
        left: 0;
    }

    /* Overlay when sidebar is open */
    .admin-sidebar.active::before {
        content: '';
        position: fixed;
        top: 0;
        left: 280px;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
    }

    .admin-content {
        padding: 1rem;
        width: 100%;
    }

    .admin-hamburger {
        display: flex !important;
        position: fixed;
        top: 1rem;
        left: 1rem;
        z-index: 10000;
        background: var(--bg-card);
        padding: 0.5rem;
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }
}

/* Small Mobile (< 480px) */
@media (max-width: 479px) {
    .admin-content {
        padding: 0.75rem;
    }

    .admin-sidebar {
        width: 100%;
        max-width: 100vw;
    }
}

/* ========================================
   RESPONSIVE GRID SYSTEM
   ======================================== */
/* Mobile First Grid */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -0.5rem;
    margin-left: -0.5rem;
}

.col {
    flex: 1 0 0%;
    padding-right: 0.5rem;
    padding-left: 0.5rem;
}

/* Column Sizes - Mobile */
.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%;
}

/* Tablet Columns */
@media (min-width: 768px) {
    .col-md-12 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .col-md-11 {
        flex: 0 0 91.666667%;
        max-width: 91.666667%;
    }

    .col-md-10 {
        flex: 0 0 83.333333%;
        max-width: 83.333333%;
    }

    .col-md-9 {
        flex: 0 0 75%;
        max-width: 75%;
    }

    .col-md-8 {
        flex: 0 0 66.666667%;
        max-width: 66.666667%;
    }

    .col-md-7 {
        flex: 0 0 58.333333%;
        max-width: 58.333333%;
    }

    .col-md-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .col-md-5 {
        flex: 0 0 41.666667%;
        max-width: 41.666667%;
    }

    .col-md-4 {
        flex: 0 0 33.333333%;
        max-width: 33.333333%;
    }

    .col-md-3 {
        flex: 0 0 25%;
        max-width: 25%;
    }

    .col-md-2 {
        flex: 0 0 16.666667%;
        max-width: 16.666667%;
    }

    .col-md-1 {
        flex: 0 0 8.333333%;
        max-width: 8.333333%;
    }
}

/* Desktop Columns */
@media (min-width: 1024px) {
    .col-lg-12 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .col-lg-11 {
        flex: 0 0 91.666667%;
        max-width: 91.666667%;
    }

    .col-lg-10 {
        flex: 0 0 83.333333%;
        max-width: 83.333333%;
    }

    .col-lg-9 {
        flex: 0 0 75%;
        max-width: 75%;
    }

    .col-lg-8 {
        flex: 0 0 66.666667%;
        max-width: 66.666667%;
    }

    .col-lg-7 {
        flex: 0 0 58.333333%;
        max-width: 58.333333%;
    }

    .col-lg-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .col-lg-5 {
        flex: 0 0 41.666667%;
        max-width: 41.666667%;
    }

    .col-lg-4 {
        flex: 0 0 33.333333%;
        max-width: 33.333333%;
    }

    .col-lg-3 {
        flex: 0 0 25%;
        max-width: 25%;
    }

    .col-lg-2 {
        flex: 0 0 16.666667%;
        max-width: 16.666667%;
    }

    .col-lg-1 {
        flex: 0 0 8.333333%;
        max-width: 8.333333%;
    }
}

/* ========================================
   RESPONSIVE TABLES
   ======================================== */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1rem 0;
    border-radius: var(--radius-md);
}

/* Mobile Table Optimization - Card Stack Approach */
@media (max-width: 767px) {
    .table-responsive {
        border: 0;
        overflow-x: hidden;
    }

    .table-stack {
        width: 100%;
        border-collapse: separate;
        border-spacing: 0 0.75rem;
    }

    .table-stack thead {
        display: none;
    }

    .table-stack tbody tr {
        display: block;
        background: rgba(15, 23, 42, 0.6);
        border: 1px solid var(--glass-border);
        border-radius: 12px;
        padding: 0.75rem 1rem;
        margin-bottom: 0.5rem;
    }

    .table-stack td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: 0.5rem 0;
        border: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        text-align: right;
        white-space: normal;
        word-break: break-word;
        font-size: 0.85rem;
    }

    .table-stack td:last-child {
        border-bottom: none;
        padding-top: 0.75rem;
    }

    .table-stack td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--primary);
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        margin-right: 1rem;
        flex-shrink: 0;
        min-width: 80px;
        text-align: left;
    }

    .table-stack td .flex,
    .table-stack td form.flex {
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 0.5rem;
    }

    .table-stack td .btn-sm,
    .table-stack .btn-sm {
        padding: 0.35rem 0.6rem;
        font-size: 0.7rem;
    }

    .table-stack code {
        font-size: 0.7rem;
        padding: 0.15rem 0.3rem;
        word-break: break-all;
    }

    .table-stack .badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }
}

/* ========================================
   RESPONSIVE CARDS
   ======================================== */
.card-responsive {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

@media (min-width: 768px) {
    .card-responsive {
        padding: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .card-responsive {
        padding: 2rem;
    }
}

/* ========================================
   RESPONSIVE FORMS
   ======================================== */
.form-responsive {
    width: 100%;
}

.form-group {
    margin-bottom: 1rem;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.form-row>* {
    flex: 1 1 100%;
}

@media (min-width: 768px) {
    .form-row>* {
        flex: 1 1 calc(50% - 0.5rem);
    }

    .form-row.three-col>* {
        flex: 1 1 calc(33.333% - 0.67rem);
    }
}

/* Form Input Responsive Sizing */
input,
select,
textarea {
    font-size: 16px;
    /* Prevents zoom on iOS */
}

@media (min-width: 768px) {

    input,
    select,
    textarea {
        font-size: 1rem;
    }
}

/* ========================================
   RESPONSIVE BUTTONS
   ======================================== */
.btn-responsive {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    width: auto;
}

@media (max-width: 767px) {
    .btn-responsive {
        width: 100%;
        padding: 0.85rem 1rem;
        margin-bottom: 0.5rem;
    }

    .btn-group-responsive {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .btn-group-responsive .btn {
        width: 100%;
    }
}

@media (min-width: 768px) {
    .btn-group-responsive {
        display: flex;
        gap: 1rem;
        flex-wrap: wrap;
    }

    .btn-group-responsive .btn {
        flex: 0 1 auto;
    }
}

/* ========================================
   RESPONSIVE STATISTICS CARDS
   ======================================== */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 480px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.stat-card-responsive {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card-responsive:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.stat-value-responsive {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.stat-label-responsive {
    font-size: clamp(0.85rem, 2vw, 1rem);
    color: var(--text-muted);
}

/* ========================================
   RESPONSIVE NAVIGATION
   ======================================== */
.nav-responsive {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

@media (min-width: 768px) {
    .nav-responsive {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

/* ========================================
   RESPONSIVE MODALS
   ======================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 1rem;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

@media (max-width: 767px) {
    .modal-content {
        padding: 1rem;
        max-width: 100%;
        border-radius: var(--radius-md);
    }
}

/* ========================================
   RESPONSIVE UTILITIES
   ======================================== */
/* Display Utilities */
.hide-mobile {
    display: none !important;
}

@media (min-width: 768px) {
    .hide-mobile {
        display: block !important;
    }

    .hide-desktop {
        display: none !important;
    }
}

.hide-tablet {
    display: block !important;
}

@media (min-width: 768px) and (max-width: 1023px) {
    .hide-tablet {
        display: none !important;
    }
}

/* Text Alignment */
.text-center-mobile {
    text-align: center;
}

@media (min-width: 768px) {
    .text-center-mobile {
        text-align: left;
    }
}

/* Spacing Utilities */
.p-responsive {
    padding: 1rem;
}

@media (min-width: 768px) {
    .p-responsive {
        padding: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .p-responsive {
        padding: 2rem;
    }
}

.m-responsive {
    margin: 1rem;
}

@media (min-width: 768px) {
    .m-responsive {
        margin: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .m-responsive {
        margin: 2rem;
    }
}

/* ========================================
   RESPONSIVE IMAGES
   ======================================== */
.img-responsive {
    max-width: 100%;
    height: auto;
    display: block;
}

.img-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.img-contain {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ========================================
   RESPONSIVE FLEXBOX UTILITIES
   ======================================== */
.flex-responsive {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (min-width: 768px) {
    .flex-responsive {
        flex-direction: row;
        align-items: center;
    }
}

.flex-wrap-responsive {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

/* ========================================
   TOUCH-FRIENDLY ELEMENTS
   ======================================== */
@media (hover: none) and (pointer: coarse) {

    /* Increase touch targets on touch devices */
    .btn,
    .nav-item,
    a,
    button {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Remove hover effects on touch devices */
    .card:hover,
    .btn:hover,
    .nav-item:hover {
        transform: none;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {

    .admin-sidebar,
    .admin-hamburger,
    .btn,
    .no-print {
        display: none !important;
    }

    .admin-layout {
        grid-template-columns: 1fr;
    }

    .admin-content {
        padding: 0;
    }

    body {
        background: white;
        color: black;
    }

    .card {
        border: 1px solid #000;
        page-break-inside: avoid;
    }
}

/* ========================================
   ACCESSIBILITY IMPROVEMENTS
   ======================================== */
/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Skip to main content link */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: white;
    padding: 0.5rem 1rem;
    text-decoration: none;
    z-index: 100000;
}

.skip-to-main:focus {
    top: 0;
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */
/* GPU acceleration for animations */
.gpu-accelerated {
    transform: translateZ(0);
    will-change: transform;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}