/**
 * FlipSecure Responsive Framework
 * Requirements: 9.2, 9.6 - Mobile-first responsive design and consistent visual design
 */

/* ===== MOBILE-FIRST RESPONSIVE FRAMEWORK ===== */

/* Base Variables for Consistent Design */
:root {
    /* Breakpoints */
    --breakpoint-xs: 320px;
    --breakpoint-sm: 576px;
    --breakpoint-md: 768px;
    --breakpoint-lg: 992px;
    --breakpoint-xl: 1200px;
    --breakpoint-xxl: 1400px;
    
    /* Spacing Scale */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-xxl: 3rem;
    
    /* Typography Scale */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;
    
    /* Touch Target Sizes */
    --touch-target-min: 44px;
    --touch-target-comfortable: 48px;
    
    /* Container Widths */
    --container-sm: 540px;
    --container-md: 720px;
    --container-lg: 960px;
    --container-xl: 1140px;
    --container-xxl: 1320px;
    
    /* Z-index Scale */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
    --z-toast: 1080;
}

/* ===== CONTAINER SYSTEM ===== */

.container {
    width: 100%;
    padding-right: var(--space-md);
    padding-left: var(--space-md);
    margin-right: auto;
    margin-left: auto;
}

.container-fluid {
    width: 100%;
    padding-right: var(--space-md);
    padding-left: var(--space-md);
    margin-right: auto;
    margin-left: auto;
}

/* ===== RESPONSIVE GRID SYSTEM ===== */

.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: calc(var(--space-md) * -0.5);
    margin-left: calc(var(--space-md) * -0.5);
}

.col {
    flex: 1 0 0%;
    padding-right: calc(var(--space-md) * 0.5);
    padding-left: calc(var(--space-md) * 0.5);
}

/* Column Classes */
.col-1 { flex: 0 0 auto; width: 8.33333333%; }
.col-2 { flex: 0 0 auto; width: 16.66666667%; }
.col-3 { flex: 0 0 auto; width: 25%; }
.col-4 { flex: 0 0 auto; width: 33.33333333%; }
.col-5 { flex: 0 0 auto; width: 41.66666667%; }
.col-6 { flex: 0 0 auto; width: 50%; }
.col-7 { flex: 0 0 auto; width: 58.33333333%; }
.col-8 { flex: 0 0 auto; width: 66.66666667%; }
.col-9 { flex: 0 0 auto; width: 75%; }
.col-10 { flex: 0 0 auto; width: 83.33333333%; }
.col-11 { flex: 0 0 auto; width: 91.66666667%; }
.col-12 { flex: 0 0 auto; width: 100%; }

/* ===== TOUCH-FRIENDLY INTERFACE ELEMENTS ===== */

/* Enhanced Button Styles for Touch */
.btn-touch {
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
    padding: var(--space-sm) var(--space-lg);
    font-size: var(--text-base);
    line-height: 1.5;
    border-radius: 8px;
    transition: all 0.2s ease-in-out;
    position: relative;
    overflow: hidden;
}

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

.btn-touch:active::before {
    width: 300px;
    height: 300px;
}

.btn-touch > * {
    position: relative;
    z-index: 1;
}

/* Touch-friendly Form Controls */
.form-control-touch {
    min-height: var(--touch-target-comfortable);
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-base);
    border-radius: 8px;
    border: 2px solid #e9ecef;
    transition: all 0.2s ease-in-out;
}

.form-control-touch:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
    outline: none;
}

/* Touch-friendly Navigation */
.nav-touch {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.nav-touch .nav-link {
    min-height: var(--touch-target-min);
    padding: var(--space-sm) var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease-in-out;
}

/* ===== RESPONSIVE UTILITIES ===== */

/* Display Utilities */
.d-none { display: none !important; }
.d-inline { display: inline !important; }
.d-inline-block { display: inline-block !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
.d-grid { display: grid !important; }

/* Flex Utilities */
.flex-row { flex-direction: row !important; }
.flex-column { flex-direction: column !important; }
.flex-wrap { flex-wrap: wrap !important; }
.flex-nowrap { flex-wrap: nowrap !important; }
.justify-content-start { justify-content: flex-start !important; }
.justify-content-end { justify-content: flex-end !important; }
.justify-content-center { justify-content: center !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-around { justify-content: space-around !important; }
.align-items-start { align-items: flex-start !important; }
.align-items-end { align-items: flex-end !important; }
.align-items-center { align-items: center !important; }
.align-items-stretch { align-items: stretch !important; }

/* Spacing Utilities */
.m-0 { margin: 0 !important; }
.m-1 { margin: var(--space-xs) !important; }
.m-2 { margin: var(--space-sm) !important; }
.m-3 { margin: var(--space-md) !important; }
.m-4 { margin: var(--space-lg) !important; }
.m-5 { margin: var(--space-xl) !important; }

.p-0 { padding: 0 !important; }
.p-1 { padding: var(--space-xs) !important; }
.p-2 { padding: var(--space-sm) !important; }
.p-3 { padding: var(--space-md) !important; }
.p-4 { padding: var(--space-lg) !important; }
.p-5 { padding: var(--space-xl) !important; }

/* Text Utilities */
.text-left { text-align: left !important; }
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }
.text-nowrap { white-space: nowrap !important; }
.text-truncate {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

/* ===== RESPONSIVE BREAKPOINTS ===== */

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) {
    .container {
        max-width: var(--container-sm);
    }
    
    /* Column Classes for SM */
    .col-sm-1 { flex: 0 0 auto; width: 8.33333333%; }
    .col-sm-2 { flex: 0 0 auto; width: 16.66666667%; }
    .col-sm-3 { flex: 0 0 auto; width: 25%; }
    .col-sm-4 { flex: 0 0 auto; width: 33.33333333%; }
    .col-sm-5 { flex: 0 0 auto; width: 41.66666667%; }
    .col-sm-6 { flex: 0 0 auto; width: 50%; }
    .col-sm-7 { flex: 0 0 auto; width: 58.33333333%; }
    .col-sm-8 { flex: 0 0 auto; width: 66.66666667%; }
    .col-sm-9 { flex: 0 0 auto; width: 75%; }
    .col-sm-10 { flex: 0 0 auto; width: 83.33333333%; }
    .col-sm-11 { flex: 0 0 auto; width: 91.66666667%; }
    .col-sm-12 { flex: 0 0 auto; width: 100%; }
    
    /* Display Utilities for SM */
    .d-sm-none { display: none !important; }
    .d-sm-inline { display: inline !important; }
    .d-sm-inline-block { display: inline-block !important; }
    .d-sm-block { display: block !important; }
    .d-sm-flex { display: flex !important; }
    .d-sm-inline-flex { display: inline-flex !important; }
    .d-sm-grid { display: grid !important; }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) {
    .container {
        max-width: var(--container-md);
    }
    
    /* Column Classes for MD */
    .col-md-1 { flex: 0 0 auto; width: 8.33333333%; }
    .col-md-2 { flex: 0 0 auto; width: 16.66666667%; }
    .col-md-3 { flex: 0 0 auto; width: 25%; }
    .col-md-4 { flex: 0 0 auto; width: 33.33333333%; }
    .col-md-5 { flex: 0 0 auto; width: 41.66666667%; }
    .col-md-6 { flex: 0 0 auto; width: 50%; }
    .col-md-7 { flex: 0 0 auto; width: 58.33333333%; }
    .col-md-8 { flex: 0 0 auto; width: 66.66666667%; }
    .col-md-9 { flex: 0 0 auto; width: 75%; }
    .col-md-10 { flex: 0 0 auto; width: 83.33333333%; }
    .col-md-11 { flex: 0 0 auto; width: 91.66666667%; }
    .col-md-12 { flex: 0 0 auto; width: 100%; }
    
    /* Display Utilities for MD */
    .d-md-none { display: none !important; }
    .d-md-inline { display: inline !important; }
    .d-md-inline-block { display: inline-block !important; }
    .d-md-block { display: block !important; }
    .d-md-flex { display: flex !important; }
    .d-md-inline-flex { display: inline-flex !important; }
    .d-md-grid { display: grid !important; }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
    .container {
        max-width: var(--container-lg);
    }
    
    /* Column Classes for LG */
    .col-lg-1 { flex: 0 0 auto; width: 8.33333333%; }
    .col-lg-2 { flex: 0 0 auto; width: 16.66666667%; }
    .col-lg-3 { flex: 0 0 auto; width: 25%; }
    .col-lg-4 { flex: 0 0 auto; width: 33.33333333%; }
    .col-lg-5 { flex: 0 0 auto; width: 41.66666667%; }
    .col-lg-6 { flex: 0 0 auto; width: 50%; }
    .col-lg-7 { flex: 0 0 auto; width: 58.33333333%; }
    .col-lg-8 { flex: 0 0 auto; width: 66.66666667%; }
    .col-lg-9 { flex: 0 0 auto; width: 75%; }
    .col-lg-10 { flex: 0 0 auto; width: 83.33333333%; }
    .col-lg-11 { flex: 0 0 auto; width: 91.66666667%; }
    .col-lg-12 { flex: 0 0 auto; width: 100%; }
    
    /* Display Utilities for LG */
    .d-lg-none { display: none !important; }
    .d-lg-inline { display: inline !important; }
    .d-lg-inline-block { display: inline-block !important; }
    .d-lg-block { display: block !important; }
    .d-lg-flex { display: flex !important; }
    .d-lg-inline-flex { display: inline-flex !important; }
    .d-lg-grid { display: grid !important; }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    .container {
        max-width: var(--container-xl);
    }
    
    /* Column Classes for XL */
    .col-xl-1 { flex: 0 0 auto; width: 8.33333333%; }
    .col-xl-2 { flex: 0 0 auto; width: 16.66666667%; }
    .col-xl-3 { flex: 0 0 auto; width: 25%; }
    .col-xl-4 { flex: 0 0 auto; width: 33.33333333%; }
    .col-xl-5 { flex: 0 0 auto; width: 41.66666667%; }
    .col-xl-6 { flex: 0 0 auto; width: 50%; }
    .col-xl-7 { flex: 0 0 auto; width: 58.33333333%; }
    .col-xl-8 { flex: 0 0 auto; width: 66.66666667%; }
    .col-xl-9 { flex: 0 0 auto; width: 75%; }
    .col-xl-10 { flex: 0 0 auto; width: 83.33333333%; }
    .col-xl-11 { flex: 0 0 auto; width: 91.66666667%; }
    .col-xl-12 { flex: 0 0 auto; width: 100%; }
    
    /* Display Utilities for XL */
    .d-xl-none { display: none !important; }
    .d-xl-inline { display: inline !important; }
    .d-xl-inline-block { display: inline-block !important; }
    .d-xl-block { display: block !important; }
    .d-xl-flex { display: flex !important; }
    .d-xl-inline-flex { display: inline-flex !important; }
    .d-xl-grid { display: grid !important; }
}

/* ===== MOBILE-SPECIFIC ENHANCEMENTS ===== */

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Ensure all interactive elements meet touch target requirements */
    .btn,
    .nav-link,
    .form-control,
    .modal-close,
    input[type="button"],
    input[type="submit"],
    input[type="reset"],
    button {
        min-height: var(--touch-target-min);
        min-width: var(--touch-target-min);
    }
    
    /* Increase spacing for better touch interaction */
    .btn + .btn,
    .nav-link + .nav-link {
        margin-left: var(--space-sm);
    }
    
    /* Remove hover effects on touch devices */
    .btn:hover,
    .nav-link:hover,
    .card:hover {
        transform: none;
    }
    
    /* Add active states for better touch feedback */
    .btn:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

/* ===== ACCESSIBILITY ENHANCEMENTS ===== */

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #000000;
        --secondary-color: #ffffff;
        --border-color: #000000;
        --text-color: #000000;
        --bg-color: #ffffff;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
    
    .form-control {
        border: 2px solid currentColor;
    }
}

/* Reduced motion support */
@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;
    }
}

/* ===== PRINT STYLES ===== */

@media print {
    /* Hide interactive elements */
    .btn,
    .nav-link,
    .modal,
    .dropdown,
    .tooltip,
    .popover {
        display: none !important;
    }
    
    /* Optimize layout for print */
    .container {
        max-width: none !important;
        padding: 0 !important;
    }
    
    .row {
        margin: 0 !important;
    }
    
    .col,
    [class*="col-"] {
        padding: 0 !important;
    }
    
    /* Ensure good contrast for print */
    body {
        color: #000000 !important;
        background: #ffffff !important;
    }
    
    /* Page break utilities */
    .page-break-before {
        page-break-before: always;
    }
    
    .page-break-after {
        page-break-after: always;
    }
    
    .page-break-inside-avoid {
        page-break-inside: avoid;
    }
}

/* ===== COMPONENT-SPECIFIC RESPONSIVE ENHANCEMENTS ===== */

/* Enhanced Card Component */
.card-responsive {
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    overflow: hidden;
}

@media (max-width: 767px) {
    .card-responsive {
        border-radius: 8px;
        margin-bottom: var(--space-md);
    }
}

/* Enhanced Modal Component */
.modal-responsive .modal-content {
    border-radius: 12px;
    max-height: 90vh;
    overflow-y: auto;
}

@media (max-width: 767px) {
    .modal-responsive {
        padding: var(--space-sm);
    }
    
    .modal-responsive .modal-content {
        border-radius: 8px;
        margin: 0;
        max-width: none;
        width: 100%;
    }
}

/* Enhanced Table Component */
.table-responsive-stack {
    overflow-x: auto;
}

@media (max-width: 767px) {
    .table-responsive-stack table,
    .table-responsive-stack thead,
    .table-responsive-stack tbody,
    .table-responsive-stack th,
    .table-responsive-stack td,
    .table-responsive-stack tr {
        display: block;
    }
    
    .table-responsive-stack thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    .table-responsive-stack tr {
        border: 1px solid #e9ecef;
        border-radius: 8px;
        margin-bottom: var(--space-md);
        padding: var(--space-md);
        background: white;
    }
    
    .table-responsive-stack td {
        border: none;
        padding: var(--space-sm) 0;
        position: relative;
        padding-left: 30%;
    }
    
    .table-responsive-stack td:before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 25%;
        padding-right: var(--space-sm);
        white-space: nowrap;
        font-weight: 600;
        color: #2c3e50;
    }
}