/**
 * Helius - Responsive Stylesheet
 * All responsive breakpoints and mobile-first styles
 * =================================================
 */

/* ============================================================================
   BREAKPOINT VARIABLES (Reference)
   ============================================================================
   Mobile Small:    320px  - 480px
   Mobile Large:    481px  - 767px
   Tablet:          768px  - 1024px
   Desktop:         1025px - 1200px
   Large Desktop:   1201px+
   ============================================================================ */

/* ============================================================================
   CONTAINER WIDTHS
   ============================================================================ */

.container {
    width: 100%;
    padding-left: 1rem;
    padding-right: 1rem;
    margin-left: auto;
    margin-right: auto;
}

@media (min-width: 576px) {
    .container { max-width: 540px; }
}

@media (min-width: 768px) {
    .container { max-width: 720px; padding-left: 1.5rem; padding-right: 1.5rem; }
}

@media (min-width: 992px) {
    .container { max-width: 960px; }
}

@media (min-width: 1200px) {
    .container { max-width: 1140px; padding-left: 2rem; padding-right: 2rem; }
}

@media (min-width: 1400px) {
    .container { max-width: 1320px; }
}

.container-fluid {
    width: 100%;
    padding-left: 1rem;
    padding-right: 1rem;
}

@media (min-width: 768px) {
    .container-fluid { padding-left: 1.5rem; padding-right: 1.5rem; }
}

@media (min-width: 1200px) {
    .container-fluid { padding-left: 2rem; padding-right: 2rem; }
}

/* ============================================================================
   TYPOGRAPHY RESPONSIVE
   ============================================================================ */

/* Mobile Small (320px - 480px) */
@media (max-width: 480px) {
    html { font-size: 14px; }
    
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: 1.125rem; }
    h5 { font-size: 1rem; }
    h6 { font-size: 0.875rem; }
}

/* Mobile Large (481px - 767px) */
@media (min-width: 481px) and (max-width: 767px) {
    html { font-size: 15px; }
    
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }
}

/* Tablet (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    html { font-size: 15px; }
    
    h1 { font-size: 2.25rem; }
    h2 { font-size: 1.875rem; }
}

/* Desktop (1025px+) */
@media (min-width: 1025px) {
    html { font-size: 16px; }
}

/* ============================================================================
   GRID RESPONSIVE UTILITIES
   ============================================================================ */

/* Hide elements at breakpoints */
@media (max-width: 575px) {
    .d-none-xs { display: none !important; }
}

@media (min-width: 576px) and (max-width: 767px) {
    .d-none-sm { display: none !important; }
}

@media (min-width: 768px) and (max-width: 991px) {
    .d-none-md { display: none !important; }
}

@media (min-width: 992px) and (max-width: 1199px) {
    .d-none-lg { display: none !important; }
}

@media (min-width: 1200px) {
    .d-none-xl { display: none !important; }
}

/* Show only on specific breakpoints */
.d-block-xs, .d-block-sm, .d-block-md, .d-block-lg, .d-block-xl {
    display: none !important;
}

@media (max-width: 575px) {
    .d-block-xs { display: block !important; }
}

@media (min-width: 576px) and (max-width: 767px) {
    .d-block-sm { display: block !important; }
}

@media (min-width: 768px) and (max-width: 991px) {
    .d-block-md { display: block !important; }
}

@media (min-width: 992px) and (max-width: 1199px) {
    .d-block-lg { display: block !important; }
}

@media (min-width: 1200px) {
    .d-block-xl { display: block !important; }
}

/* Mobile only */
@media (max-width: 767px) {
    .d-mobile-none { display: none !important; }
    .d-mobile-block { display: block !important; }
    .d-mobile-flex { display: flex !important; }
}

/* Desktop only */
@media (min-width: 768px) {
    .d-desktop-none { display: none !important; }
    .d-desktop-block { display: block !important; }
    .d-desktop-flex { display: flex !important; }
}

/* ============================================================================
   SPACING RESPONSIVE
   ============================================================================ */

@media (max-width: 767px) {
    .p-mobile-0 { padding: 0 !important; }
    .p-mobile-1 { padding: 0.5rem !important; }
    .p-mobile-2 { padding: 1rem !important; }
    .p-mobile-3 { padding: 1.5rem !important; }
    
    .m-mobile-0 { margin: 0 !important; }
    .m-mobile-1 { margin: 0.5rem !important; }
    .m-mobile-2 { margin: 1rem !important; }
    .m-mobile-auto { margin: auto !important; }
    
    .px-mobile-0 { padding-left: 0 !important; padding-right: 0 !important; }
    .px-mobile-2 { padding-left: 1rem !important; padding-right: 1rem !important; }
    
    .py-mobile-2 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
    .py-mobile-3 { padding-top: 1.5rem !important; padding-bottom: 1.5rem !important; }
    
    .mb-mobile-2 { margin-bottom: 1rem !important; }
    .mb-mobile-3 { margin-bottom: 1.5rem !important; }
    .mb-mobile-4 { margin-bottom: 2rem !important; }
    
    .mt-mobile-2 { margin-top: 1rem !important; }
    .mt-mobile-3 { margin-top: 1.5rem !important; }
}

/* ============================================================================
   BUTTONS RESPONSIVE
   ============================================================================ */

@media (max-width: 480px) {
    .btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.8125rem;
    }
    
    .btn-lg {
        padding: 0.875rem 1.5rem;
        font-size: 0.875rem;
    }
    
    .btn-block-mobile {
        display: block;
        width: 100%;
    }
    
    .btn-group-mobile {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .btn-group-mobile .btn {
        width: 100%;
    }
}

/* ============================================================================
   CARDS RESPONSIVE
   ============================================================================ */

@media (max-width: 767px) {
    .card-body {
        padding: 1rem;
    }
    
    .card-header,
    .card-footer {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .card-body {
        padding: 0.875rem;
    }
    
    .card-header,
    .card-footer {
        padding: 0.875rem;
    }
}

/* ============================================================================
   TABLES RESPONSIVE
   ============================================================================ */

@media (max-width: 767px) {
    .table-responsive-stack {
        display: block;
    }
    
    .table-responsive-stack thead {
        display: none;
    }
    
    .table-responsive-stack tbody tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
    }
    
    .table-responsive-stack tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem 1rem;
        border-bottom: 1px solid var(--border-color);
    }
    
    .table-responsive-stack tbody td:last-child {
        border-bottom: none;
    }
    
    .table-responsive-stack tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        font-size: var(--fs-xs);
        text-transform: uppercase;
    }
}

/* Standard responsive table scroll */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 991px) {
    .table th,
    .table td {
        padding: 0.75rem;
        font-size: 0.8125rem;
    }
}

@media (max-width: 767px) {
    .table th,
    .table td {
        padding: 0.625rem;
        font-size: 0.75rem;
    }
    
    .table th {
        white-space: nowrap;
    }
}

/* ============================================================================
   FORMS RESPONSIVE
   ============================================================================ */

@media (max-width: 767px) {
    .form-control {
        padding: 0.75rem;
        font-size: 16px; /* Prevents iOS zoom */
    }
    
    .form-label {
        font-size: 0.8125rem;
    }
    
    .form-group {
        margin-bottom: 1rem;
    }
    
    .input-group {
        flex-wrap: nowrap;
    }
    
    .input-group .form-control {
        flex: 1 1 auto;
        min-width: 0;
    }
    
    .input-group-text {
        flex: 0 0 auto;
    }
}

@media (max-width: 480px) {
    .form-row {
        flex-direction: column;
    }
    
    .form-row > * {
        margin-bottom: 1rem;
    }
    
    .form-row > *:last-child {
        margin-bottom: 0;
    }
}

/* ============================================================================
   MODALS RESPONSIVE
   ============================================================================ */

@media (max-width: 575px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }
    
    .modal-title {
        font-size: 1.125rem;
    }
    
    .modal-fullscreen-mobile {
        max-width: 100%;
        margin: 0;
        height: 100%;
    }
    
    .modal-fullscreen-mobile .modal-content {
        height: 100%;
        border-radius: 0;
    }
}

/* ============================================================================
   NAVIGATION RESPONSIVE
   ============================================================================ */

@media (max-width: 991px) {
    .navbar-collapse {
        position: fixed;
        top: 0;
        left: -100%;
        width: 280px;
        height: 100vh;
        background: var(--bg-card);
        padding: 1.5rem;
        transition: left var(--transition-normal);
        z-index: 1050;
        overflow-y: auto;
        border-right: 1px solid var(--border-color);
    }
    
    .navbar-collapse.show {
        left: 0;
    }
    
    .navbar-backdrop {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1040;
    }
    
    .navbar-collapse.show + .navbar-backdrop {
        display: block;
    }
    
    .nav-item {
        margin: 0;
        border-bottom: 1px solid var(--border-color);
    }
    
    .nav-link {
        padding: 1rem 0;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
}

/* ============================================================================
   SIDEBAR RESPONSIVE
   ============================================================================ */

/* Sidebar responsive handled in user.css (transform-based) */

/* ============================================================================
   HERO SECTION RESPONSIVE
   ============================================================================ */

@media (max-width: 991px) {
    .hero-section {
        padding: 4rem 0;
        min-height: auto;
    }
    
    .hero-content {
        text-align: center;
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .hero-buttons {
        flex-direction: column;
        gap: 1rem;
    }
    
    .hero-buttons .btn {
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
    }
}

@media (max-width: 480px) {
    .hero-section {
        padding: 3rem 0;
    }
    
    .hero-title {
        font-size: 1.75rem;
    }
}

/* ============================================================================
   STATS / WIDGETS RESPONSIVE
   ============================================================================ */

@media (max-width: 767px) {
    .stat-card {
        padding: 1rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .stat-label {
        font-size: 0.75rem;
    }
    
    .widget-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    .widget-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================================================
   DASHBOARD RESPONSIVE
   ============================================================================ */

@media (max-width: 767px) {
    .dashboard-header {
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
    }
    
    .header-left {
        flex: 1;
        min-width: 0;
    }
    
    .header-left .page-title {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .header-right {
        flex-shrink: 0;
    }
    
    .dashboard-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .quick-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .quick-stats {
        grid-template-columns: 1fr;
    }
}

/* ============================================================================
   FOOTER RESPONSIVE
   ============================================================================ */

@media (max-width: 767px) {
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
    }
    
    .footer-links {
        justify-content: center;
    }
    
    .footer-social {
        justify-content: center;
    }
    
    .footer-bottom {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

/* ============================================================================
   FLEX UTILITIES RESPONSIVE
   ============================================================================ */

@media (max-width: 767px) {
    .flex-mobile-column {
        flex-direction: column !important;
    }
    
    .flex-mobile-wrap {
        flex-wrap: wrap !important;
    }
    
    .justify-mobile-center {
        justify-content: center !important;
    }
    
    .align-mobile-center {
        align-items: center !important;
    }
    
    .gap-mobile-2 {
        gap: 1rem !important;
    }
}

/* ============================================================================
   TEXT ALIGNMENT RESPONSIVE
   ============================================================================ */

@media (max-width: 767px) {
    .text-mobile-center {
        text-align: center !important;
    }
    
    .text-mobile-left {
        text-align: left !important;
    }
}

@media (min-width: 768px) {
    .text-desktop-left {
        text-align: left !important;
    }
    
    .text-desktop-center {
        text-align: center !important;
    }
}

/* ============================================================================
   WIDTH UTILITIES RESPONSIVE
   ============================================================================ */

@media (max-width: 767px) {
    .w-mobile-100 {
        width: 100% !important;
    }
    
    .w-mobile-auto {
        width: auto !important;
    }
}

/* ============================================================================
   IMAGE RESPONSIVE
   ============================================================================ */

.img-fluid {
    max-width: 100%;
    height: auto;
}

@media (max-width: 767px) {
    .img-mobile-full {
        width: 100%;
        height: auto;
    }
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    .card {
        border: 1px solid #ddd !important;
        box-shadow: none !important;
    }
    
    a {
        color: black !important;
        text-decoration: underline;
    }
    
    .btn {
        display: none !important;
    }
}

/* ============================================================================
   TOUCH DEVICE OPTIMIZATIONS
   ============================================================================ */

@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn {
        min-height: 44px;
    }
    
    .nav-link {
        min-height: 44px;
    }
    
    .dropdown-item {
        padding: 0.875rem 1rem;
    }
    
    /* Remove hover effects on touch */
    .card:hover {
        transform: none;
    }
    
    .btn:hover {
        transform: none;
    }
}

/* ============================================================================
   HIGH DPI / RETINA SCREENS
   ============================================================================ */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Use higher resolution images if available */
    .logo-img {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* ============================================================================
   LANDSCAPE MOBILE
   ============================================================================ */

@media (max-height: 500px) and (orientation: landscape) {
    .hero-section {
        min-height: auto;
        padding: 2rem 0;
    }
    
    .modal-dialog {
        margin: 0.5rem auto;
        max-height: calc(100vh - 1rem);
    }
    
    .modal-body {
        max-height: calc(100vh - 150px);
        overflow-y: auto;
    }
}

/* ============================================================================
   SAFE AREA (iPhone X+)
   ============================================================================ */

@supports (padding: max(0px)) {
    .safe-area-bottom {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
    
    .safe-area-top {
        padding-top: max(1rem, env(safe-area-inset-top));
    }
    
    .fixed-bottom-safe {
        bottom: env(safe-area-inset-bottom);
    }
}
