/* PMS Responsive Design - Mobile-First Approach */

/* Global overflow prevention */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

/* Prevent body scroll when sidebar is open on mobile */
body.sidebar-open {
    position: fixed;
    width: 100%;
    overflow: hidden;
}

/* Responsive images */
img {
    max-width: 100%;
    height: auto;
}

/* Mobile Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 1040;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.show {
    display: block;
}

/* Mobile Sidebar */
@media (max-width: 991px) {
    .app-sidebar {
        position: fixed !important;
        top: 0 !important;
        left: -280px !important;
        width: 280px !important;
        height: 100dvh !important;
        z-index: 1050 !important;
        transition: left 0.25s ease !important;
        overflow-y: auto !important;
        margin: 0 !important;
        min-height: 100vh !important;
    }
    
    .app-sidebar.show {
        left: 0 !important;
    }
    
    .app-main,
    .main-content {
        margin-left: 0 !important;
        width: 100%;
    }
}

/* Breakpoints */
@media (min-width: 1200px) {
    .dashboard-card {
        min-height: 140px !important;
    }
}

@media (max-width: 1199px) {
    .dashboard-card {
        min-height: 130px !important;
    }
}

@media (max-width: 991px) {
    .dashboard-card {
        min-height: 120px !important;
    }
}

/* Typography Responsive */
@media (max-width: 767px) {
    body {
        font-size: 14px;
    }
    
    .page-title {
        font-size: 20px;
    }
    
    .card-title,
    .card-header h5 {
        font-size: 16px;
    }
    
    .table {
        font-size: 13px;
    }
}

/* Quick action buttons - larger screens in flex */
@media (min-width: 768px) {
    .quick-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .quick-actions .btn {
        min-height: 40px;
    }
}

/* Tablet - quick-actions stack to 2 columns */
@media (max-width: 991px) {
    .quick-actions {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .quick-actions .btn {
        width: 100%;
        min-height: 40px;
    }
}

/* Mobile - 576px and below */
@media (max-width: 576px) {
    /* Login page */
    .login-body {
        min-height: 100dvh;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 28px 16px 20px;
        display: flex;
        align-items: flex-start;
        justify-content: center;
    }
    
    .login-wrapper {
        width: 100%;
        max-width: 420px;
        margin: 0 auto;
    }
    
    .login-card {
        width: 100%;
        max-width: 100%;
        padding: 28px 22px;
        border-radius: 12px;
        margin: 0;
    }
    
    .login-brand {
        padding: 24px 16px 0;
    }
    
    .login-logo {
        max-width: 130px;
        max-height: 80px;
        margin-bottom: 20px;
    }
    
    .login-form {
        padding: 0 20px 24px;
    }
    
    .form-control,
    .input-group .form-control {
        min-height: 42px;
    }
    
    .input-group-text {
        min-width: 42px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .login-btn {
        min-height: 44px;
        width: 100%;
    }
    
    .login-footer {
        margin-top: 18px;
        font-size: 11.5px;
        line-height: 1.45;
        padding: 0 12px;
    }
    
    .demo-credentials {
        margin-top: 20px;
        padding: 10px 12px;
        font-size: 12px;
    }
    
    /* Main content padding */
    .app-content {
        padding: 12px !important;
    }
    
    .page-title {
        font-size: 22px;
        line-height: 1.25;
    }
    
    .breadcrumb {
        font-size: 12px;
        flex-wrap: wrap;
    }
    
    /* Topbar mobile */
    .app-topbar {
        height: 56px;
        padding: 0 12px !important;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    
    .topbar-actions {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-shrink: 0;
    }
    
    .user-name {
        display: none !important;
    }
    
    .user-menu-toggle {
        min-width: auto;
        padding: 8px 10px;
        white-space: nowrap;
    }
    
    /* Quick action buttons mobile */
    .quick-actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .quick-actions .btn {
        width: 100%;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
    }
    
    /* Dashboard cards mobile */
    .dashboard-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .dashboard-card {
        padding: 16px;
        border-radius: 12px;
        min-height: auto;
    }
    
    .dashboard-card-number {
        font-size: 24px;
        font-weight: 700;
    }
    
    .dashboard-card-label {
        font-size: 13px;
    }
    
    .dashboard-card .dashboard-icon {
        width: 40px !important;
        height: 40px !important;
    }
    
    /* Filter bar */
    .filter-bar,
    .filter-form .row {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .filter-bar .btn,
    .filter-form .col-md-2 .btn,
    .filter-form .col-md-3 .btn {
        width: 100%;
        min-height: 42px;
    }
    
    /* Form grid */
    .form-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .form-actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .form-actions .btn {
        width: 100%;
        min-height: 42px;
    }
    
    /* Tables */
    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        font-size: 13px;
    }
    
    .table .btn {
        padding: 6px 8px;
        font-size: 12px;
    }
    
    /* Modals */
    .modal-dialog {
        margin: 12px;
        max-width: calc(100% - 24px);
    }
    
    .modal-footer {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .modal-footer .btn {
        width: 100%;
        min-height: 42px;
    }
    
    /* Buttons touch-friendly */
    .btn {
        min-height: 40px;
    }
    
    /* Footer */
    .app-footer {
        margin-top: 24px;
        padding: 16px 12px;
        text-align: center;
        font-size: 12px;
        line-height: 1.5;
    }
    
    /* Kanban mobile */
    .kanban-board {
        flex-wrap: nowrap;
        overflow-x: auto;
        max-width: 100%;
        padding-bottom: 12px;
        -webkit-overflow-scrolling: touch;
    }
    
    .kanban-column {
        flex: 0 0 280px;
        min-width: 280px;
    }
    
    .kanban-card {
        padding: 10px;
    }
    
    .kanban-column-header,
    .kanban-column .card-header h5 {
        font-size: 15px;
        padding: 12px 14px;
    }
    
    .kanban-filter-card .row.g-3 {
        flex-direction: column;
        gap: 12px;
    }
    
    .kanban-filter-card .col-md-3 {
        width: 100% !important;
    }
    
    .quick-filter {
        min-height: 40px;
    }
}

/* Filter form responsive */
@media (max-width: 991px) {
    .filter-form .col-md-2,
    .filter-form .col-md-3,
    .filter-form .col-md-6 {
        width: 100% !important;
    }
}

/* Tables - Card view on mobile */
@media (max-width: 767px) {
    .table thead {
        display: none;
    }
    
    .table tbody tr {
        display: block;
        margin-bottom: 16px;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        padding: 12px;
        background: #ffffff;
    }
    
    .table tbody tr td {
        display: block;
        text-align: right;
        padding: 8px 0;
        border: none;
        border-bottom: 1px solid #f3f4f6;
        position: relative;
    }
    
    .table tbody tr td:last-child {
        border-bottom: 0;
    }
    
    .table tbody tr td::before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        font-weight: 600;
        color: #374151;
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    .text-end {
        text-align: center !important;
    }
    
    .btn-group,
    .btn-group-sm {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        justify-content: flex-end;
    }
    
    .btn-group .btn {
        flex: 1;
        min-width: 40px;
    }
}

/* Modal responsive */
@media (max-width: 576px) {
    .modal-content {
        border-radius: 12px;
    }
    
    .modal-header,
    .modal-footer {
        padding: 12px 16px;
    }
    
    .modal-body {
        padding: 16px;
        max-height: 60vh;
        overflow-y: auto;
    }
}

/* Tabs Responsive */
@media (max-width: 767px) {
    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        border-bottom: 1px solid #e5e7eb;
    }
    
    .nav-tabs .nav-item {
        flex: 0 0 auto;
    }
    
    .nav-tabs .nav-link {
        white-space: nowrap;
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* Empty State Responsive */
@media (max-width: 767px) {
    .empty-state {
        padding: 32px 16px !important;
    }
    
    .empty-state .fa-3x {
        font-size: 2.5em;
    }
}

/* Alert/Flash Message Responsive */
@media (max-width: 576px) {
    .alert {
        padding: 12px 16px;
        font-size: 14px;
    }
    
    .alert .btn-close {
        position: absolute;
        right: 8px;
        top: 8px;
    }
}

/* User dropdown mobile */
@media (max-width: 767px) {
    .user-menu-dropdown {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
        transition: transform 0.3s ease;
    }
    
    .user-menu-dropdown.show {
        transform: translateY(0);
    }
    
    .user-menu-dropdown a {
        padding: 14px 20px;
        font-size: 15px;
    }
}

/* Avatar responsive */
@media (max-width: 767px) {
    .avatar-xs {
        width: 24px;
        height: 24px;
        font-size: 9px;
    }
    
    .avatar-sm {
        width: 32px;
        height: 32px;
    }
}

/* Pagination responsive */
@media (max-width: 576px) {
    .pagination {
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .pagination .page-item {
        flex: 1;
        min-width: 36px;
    }
    
    .pagination .page-link {
        padding: 8px 12px;
        font-size: 14px;
    }
}

/* Form improvements */
@media (max-width: 767px) {
    .form-label {
        margin-bottom: 4px;
        font-size: 14px;
    }
    
    .color-field-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .form-control-color {
        width: 100%;
        max-width: 120px;
    }
    
    textarea.form-control {
        min-height: 100px;
    }
}

/* Print Styles */
@media print {
    .app-sidebar,
    .app-topbar,
    .app-footer,
    .btn,
    .page-header .d-flex > a,
    .filter-form,
    .card-header-tabs,
    .kanban-filter-card {
        display: none !important;
    }
    
    .app-main {
        margin-left: 0 !important;
    }
    
    .app-content {
        padding: 0 !important;
    }
    
    .card {
        border: 1px solid #000 !important;
        break-inside: avoid;
    }
    
    .table {
        width: 100% !important;
    }
}

/* Scrollable containers */
.table-scroll-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Page header mobile */
@media (max-width: 767px) {
    .page-header .d-flex {
        flex-direction: column !important;
        gap: 12px !important;
    }
    
    .page-header .btn {
        width: 100% !important;
        margin: 2px 0 !important;
    }
}