/**
 * Responsive CSS - NaviPos Online
 * Mobile-first responsive design for all screen sizes
 */

/* ===========================
   MOBILE SIDEBAR TOGGLE
   =========================== */

/* Navbar Sidebar Controls */
.navbar-sidebar-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-right: 1rem;
}

/* Sidebar Toggle Button (Mobile - Hamburger) */
.sidebar-toggle-btn {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    transition: all 0.3s;
}

.sidebar-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
}

.sidebar-toggle-btn i {
    display: block;
}

/* Sidebar Resize Button (Desktop - Hamburger) */
.sidebar-resize-btn {
    display: block;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    transition: all 0.3s;
}

.sidebar-resize-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
}

.sidebar-resize-btn i {
    display: block;
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Submenu Styles */
.nav-item.has-submenu .submenu {
    display: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    margin: 0.25rem 0 0.5rem 0;
    padding: 0.25rem 0;
}

.nav-item.submenu-open .submenu {
    display: block;
}

.submenu-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem 0.65rem 2.75rem;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    transition: all 0.2s;
    border-radius: 4px;
    font-size: 0.875rem;
    margin: 0.15rem 0.5rem;
}

.submenu-link i {
    font-size: 0.8rem;
    width: 16px;
    text-align: center;
}

.submenu-link:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    padding-left: 3rem;
}

.submenu-link.active {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.2), transparent);
    border-left: 3px solid #10b981;
    color: white;
    font-weight: 600;
}

.submenu-arrow {
    margin-left: auto;
    font-size: 0.7rem;
    transition: transform 0.3s;
    opacity: 0.7;
}

.nav-item.submenu-open .submenu-arrow {
    transform: rotate(180deg);
}

.nav-item.has-submenu .nav-link:hover .submenu-arrow {
    opacity: 1;
}

/* Sidebar Footer */
.sidebar-footer {
    margin-top: auto;
    padding: 1rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-footer .nav-item {
    margin: 0;
}

.sidebar-footer .nav-link {
    color: #f87171;
}

.sidebar-footer .nav-link:hover {
    background: rgba(248, 113, 113, 0.1);
    color: #fca5a5;
}

/* Make sidebar flex container */
.sidebar,
.admin-sidebar {
    display: flex;
    flex-direction: column;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
}

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

/* Large Tablets and Small Desktops (1024px and below) */
@media (max-width: 1024px) {
    /* Show sidebar toggle button, hide resize button */
    .sidebar-toggle-btn {
        display: block;
    }
    
    .sidebar-resize-btn {
        display: none;
    }
    
    /* Responsive company logo */
    .company-logo {
        min-height: 50px;
    }
    
    .company-logo img {
        max-height: 50px;
    }
    
    .company-logo-placeholder {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    .sidebar-company-header .company-name {
        font-size: 0.85rem;
    }
    
    /* Mobile logout button in user section */
    .sidebar-user-logout {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }
    
    /* Sidebar transitions */
    .sidebar,
    .admin-sidebar {
        position: fixed;
        left: -250px;
        top: 0;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease-in-out;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }
    
    .sidebar.active,
    .admin-sidebar.active {
        left: 0;
    }
    
    /* Main content full width */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    /* Navbar adjustments */
    .navbar {
        left: 0 !important;
        width: 100% !important;
    }
    
    /* Dashboard stats grid */
    .dashboard-stats-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .dashboard-overview-row {
        grid-template-columns: 1fr;
    }
    
    .dashboard-main-row {
        grid-template-columns: 1fr;
    }
    
    /* Stats grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    /* Data tables */
    .data-table-wrapper {
        overflow-x: auto;
    }
    
    .data-table {
        min-width: 800px;
    }
}

/* Tablets (768px and below) */
@media (max-width: 768px) {
    /* Responsive company logo for tablets */
    .sidebar-company-header {
        padding: 0.75rem;
    }
    
    .company-logo {
        min-height: 45px;
        margin-bottom: 0.5rem;
    }
    
    .company-logo img {
        max-height: 45px;
    }
    
    .company-logo-placeholder {
        width: 45px;
        height: 45px;
        font-size: 1.25rem;
        margin: 0 auto 0.5rem;
    }
    
    .sidebar-company-header .company-name {
        font-size: 0.8rem;
        margin-bottom: 0.35rem;
    }
    
    .sidebar-company-header .company-address,
    .sidebar-company-header .company-phone,
    .sidebar-company-header .company-email {
        font-size: 0.7rem;
        margin-bottom: 0.25rem;
    }
    
    /* Page header */
    .page-header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    .page-header > div:first-child {
        width: 100%;
    }
    
    .page-breadcrumb {
        font-size: 0.875rem;
    }
    
    /* Action bar */
    .action-bar {
        flex-direction: column;
        gap: 1rem;
    }
    
    .action-buttons {
        width: 100%;
        flex-direction: column;
    }
    
    .action-buttons .btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Stats grid - single column */
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .dashboard-stats-row {
        grid-template-columns: 1fr;
    }
    
    /* Stat cards */
    .stat-card {
        padding: 1rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    /* Cards */
    .card {
        border-radius: 8px;
    }
    
    .card-header {
        padding: 1rem;
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start !important;
    }
    
    .card-header-responsive {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    .card-controls-top {
        width: 100%;
    }
    
    .card-controls {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .per-page-control {
        flex: 1;
        min-width: 150px;
        order: 1;
    }
    
    .filter-button {
        flex: 1;
        min-width: 100px;
        font-size: 0.75rem;
        padding: 0.4rem 0.5rem;
        justify-content: center;
    }
    
    .export-text,
    .refresh-text {
        display: none;
    }
    
    .card-title {
        font-size: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    /* Tables - Data Table Widget */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
    }
    
    .table-responsive-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .data-table-wrapper {
        overflow-x: auto;
    }
    
    .data-table {
        font-size: 0.875rem;
        table-layout: auto;
        min-width: 700px;
    }
    
    table {
        font-size: 0.875rem;
        width: 100%;
        table-layout: auto;
    }
    
    table th,
    table td {
        padding: 0.75rem 0.5rem;
        white-space: nowrap;
    }
    
    /* Mobile table scrolling indicator */
    .table-responsive-scroll::after,
    .data-table-wrapper::after {
        content: "← Swipe to scroll →";
        display: block;
        font-size: 0.75rem;
        color: #9ca3af;
        text-align: center;
        padding: 0.5rem;
        background: #f9fafb;
        border-top: 1px solid #e5e7eb;
    }
    
    /* Data table controls */
    .data-table-controls {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch !important;
    }
    
    .data-table-controls .data-table-search,
    .data-table-controls .data-table-per-page {
        width: 100%;
    }
    
    .data-table-controls .data-table-search input {
        width: 100%;
    }
    
    .data-table-buttons {
        width: 100%;
        justify-content: space-between;
    }
    
    .data-table-buttons .btn {
        flex: 1;
        min-width: auto;
    }
    
    /* Pagination */
    .data-table-pagination {
        flex-direction: column;
        gap: 1rem;
        align-items: center;
    }
    
    .pagination-controls {
        width: 100%;
        justify-content: center;
    }
    
    .pagination-info {
        width: 100%;
        text-align: center;
    }
    
    /* Forms */
    .form-row {
        flex-direction: column;
    }
    
    .form-group {
        width: 100%;
    }
    
    /* Buttons */
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group .btn {
        width: 100%;
        border-radius: 6px !important;
        margin-bottom: 0.5rem;
    }
    
    /* Modals */
    .modal-content {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }
}

/* Mobile Phones (480px and below) */
@media (max-width: 480px) {
    /* Ultra-responsive company logo for mobile */
    .sidebar-company-header {
        padding: 0.5rem;
    }
    
    .company-logo {
        min-height: 40px;
        margin-bottom: 0.4rem;
    }
    
    .company-logo img {
        max-height: 40px;
    }
    
    .company-logo-placeholder {
        width: 40px;
        height: 40px;
        font-size: 1rem;
        margin: 0 auto 0.4rem;
    }
    
    .sidebar-company-header .company-name {
        font-size: 0.75rem;
        margin-bottom: 0.25rem;
        font-weight: 600;
    }
    
    .sidebar-company-header .company-address,
    .sidebar-company-header .company-phone,
    .sidebar-company-header .company-email {
        font-size: 0.65rem;
        margin-bottom: 0.15rem;
    }
    
    .sidebar-company-header .company-address i,
    .sidebar-company-header .company-phone i,
    .sidebar-company-header .company-email i {
        margin-right: 0.25rem;
        font-size: 0.6rem;
    }
    
    /* Navbar */
    .navbar,
    .top-navbar {
        padding: 0.75rem 1rem;
    }
    
    .navbar-search {
        max-width: 120px;
    }
    
    .navbar-search input {
        font-size: 0.875rem;
        padding: 0.5rem 2.5rem;
    }
    
    .navbar-actions {
        gap: 0.25rem;
    }
    
    .navbar-actions .btn,
    .navbar-btn {
        padding: 0.5rem;
        font-size: 0.875rem;
    }
    
    /* Page title */
    .page-title {
        font-size: 1.25rem;
    }
    
    .page-header {
        padding: 1rem;
    }
    
    /* Stats */
    .stat-value {
        font-size: 1.25rem;
    }
    
    .stat-label {
        font-size: 0.75rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    /* Badges */
    .badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
    
    .status-badge {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }
    
    /* Buttons */
    .btn {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }
    
    .btn i {
        font-size: 0.875rem;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .action-buttons .btn {
        width: 100%;
    }
    
    /* Detail views */
    .detail-info-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .detail-info-label {
        font-size: 0.75rem;
    }
    
    .detail-info-value {
        font-size: 0.875rem;
    }
    
    .detail-section {
        padding: 1rem;
    }
    
    .detail-section-title {
        font-size: 1rem;
    }
    
    /* Dashboard cards */
    .overview-card {
        padding: 1rem;
    }
    
    .overview-header h3 {
        font-size: 0.875rem;
    }
    
    /* Activity items */
    .activity-item,
    .admin-org-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .activity-content,
    .org-content {
        width: 100%;
    }
    
    /* Data tables */
    table th,
    table td {
        padding: 0.5rem 0.4rem;
        font-size: 0.8rem;
        white-space: nowrap;
    }
    
    .data-table {
        font-size: 0.75rem;
        table-layout: auto;
        min-width: 600px;
    }
    
    .table-responsive-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border: 1px solid #e5e7eb;
        border-radius: 0 0 0.5rem 0.5rem;
    }
    
    .data-table-wrapper {
        overflow-x: auto;
        border: 1px solid #e5e7eb;
        border-radius: 0 0 0.5rem 0.5rem;
    }
    
    .data-table-controls {
        padding: 0.75rem;
    }
    
    /* Pagination on mobile */
    .pagination-wrapper {
        flex-direction: column;
        gap: 1rem;
        padding: 0.75rem;
    }
    
    .pagination {
        width: 100%;
        justify-content: center;
        gap: 0.25rem;
        flex-wrap: wrap;
    }
    
    .pagination-btn {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .pagination-info {
        text-align: center;
        font-size: 0.75rem;
    }
    
    /* Cards */
    .card {
        margin-bottom: 1rem;
    }
    
    .card-header {
        padding: 0.75rem;
    }
    
    .card-body {
        padding: 0.75rem;
    }
}

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

@media print {
    .sidebar,
    .navbar,
    .page-header,
    .action-bar,
    .btn,
    .sidebar-toggle-btn,
    .sidebar-overlay {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
    
    table {
        page-break-inside: auto;
    }
    
    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }
}

/* ===========================
   UTILITY CLASSES
   =========================== */

/* Hide on mobile */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Hide on desktop */
@media (min-width: 769px) {
    .hide-desktop {
        display: none !important;
    }
}

/* Text alignment */
@media (max-width: 768px) {
    .mobile-center {
        text-align: center !important;
    }
    
    .mobile-left {
        text-align: left !important;
    }
}

/* Spacing utilities for mobile */
@media (max-width: 768px) {
    .p-mobile-1 { padding: 0.5rem !important; }
    .p-mobile-2 { padding: 1rem !important; }
    .m-mobile-1 { margin: 0.5rem !important; }
    .m-mobile-2 { margin: 1rem !important; }
}
