/* Mobile Responsive Styles */

/* Global: Prevent horizontal scrolling */
* {
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
    width: 100% !important;
}

body {
    position: relative;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

/* ============================================
   SIDEBAR STYLES - Centralized for all pages
   ============================================ */

/* Sidebar Container */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 0;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    left: 0;
    top: 0;
}

/* Sidebar Header */
.sidebar-header {
    padding: 24px 20px;
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    text-align: center;
}

.sidebar-header img {
    max-width: 120px;
    height: auto;
    margin-bottom: 12px;
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.sidebar-header p {
    font-size: 12px;
    color: rgba(255,255,255,0.7);
}

/* Sidebar Menu */
.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* Menu Items */
.menu-item {
    display: block;
    width: 100%;
    padding: 14px 20px;
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
    box-sizing: border-box;
    clear: both;
}

.menu-item:hover {
    background: rgba(255,255,255,0.1);
    border-left-color: #3498db;
    color: white;
}

.menu-item.active {
    background: rgba(255,255,255,0.15);
    border-left-color: #3498db;
    color: white;
    font-weight: 600;
}

.menu-item i {
    margin-right: 12px;
    width: 20px;
    display: inline-block;
}

/* User Info Section */
.user-info {
    position: relative;
    width: 100%;
    padding: 20px;
    background: rgba(0,0,0,0.2);
    border-top: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
    margin-top: auto;
}

.user-info p {
    font-size: 13px;
    margin-bottom: 8px;
    color: rgba(255,255,255,0.9);
}

/* Logout Button */
.logout-btn {
    display: block;
    width: 100%;
    padding: 10px;
    background: rgba(231, 76, 60, 0.2);
    color: white;
    border: 1px solid rgba(231, 76, 60, 0.5);
    border-radius: 6px;
    text-decoration: none;
    text-align: center;
    transition: all 0.3s ease;
    font-size: 14px;
}

.logout-btn:hover {
    background: rgba(231, 76, 60, 0.3);
    border-color: rgba(231, 76, 60, 0.7);
}

/* Settings Cog Button */
.settings-cog {
    flex: 0 0 auto;
    padding: 8px;
    background: rgba(52, 152, 219, 0.2);
    border: 1px solid rgba(52, 152, 219, 0.5);
    border-radius: 6px;
    text-decoration: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.settings-cog:hover {
    background: rgba(52, 152, 219, 0.3);
    border-color: rgba(52, 152, 219, 0.7);
}

/* Main Content Area */
.main-content {
    margin-left: 260px;
    padding: 40px;
    min-height: 100vh;
    max-width: calc(100% - 260px);
    overflow-x: hidden;
}

/* Ensure menu items can display badges - use flex for content inside */
.sidebar-menu .menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    width: 100%;
    box-sizing: border-box;
}

/* Menu Groups (Collapsible) */
.menu-group {
    margin: 0;
}

.menu-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    color: rgba(255,255,255,0.9);
    cursor: pointer;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
    user-select: none;
}

.menu-group-header:hover {
    background: rgba(255,255,255,0.1);
    border-left-color: #3498db;
    color: white;
}

.menu-group-header i {
    margin-right: 12px;
    width: 20px;
    display: inline-block;
}

.menu-group-arrow {
    font-size: 12px;
    transition: transform 0.3s ease;
    color: rgba(255,255,255,0.7);
}

.menu-group.expanded .menu-group-arrow {
    transform: rotate(0deg);
}

.menu-group:not(.expanded) .menu-group-arrow {
    transform: rotate(-90deg);
}

.menu-group-items {
    display: none;
    background: rgba(0,0,0,0.1);
}

.menu-group.expanded .menu-group-items {
    display: block;
}

.menu-sub-item {
    padding-left: 45px !important;
    font-size: 13px;
    padding-top: 10px;
    padding-bottom: 10px;
}

.menu-sub-item i {
    font-size: 12px;
}

/* Notification Badge */
.notification-badge {
    display: inline-block;
    background: #e74c3c;
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: auto;
    min-width: 18px;
    text-align: center;
    line-height: 1.4;
}

/* Mobile Header */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(180deg, #2c3e50 0%, #34495e 100%);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
    align-items: center;
    padding: 0 15px;
}

.mobile-menu-toggle {
    background: none;
    border: none;
    width: 30px;
    height: 30px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    padding: 0;
    margin-right: 15px;
}

.mobile-menu-toggle span,
.mobile-menu-toggle span::before,
.mobile-menu-toggle span::after {
    display: block;
    width: 25px;
    height: 3px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.mobile-menu-toggle span::before,
.mobile-menu-toggle span::after {
    content: '';
    position: absolute;
}

.mobile-menu-toggle span::before {
    transform: translateY(-8px);
}

.mobile-menu-toggle span::after {
    transform: translateY(8px);
}

.mobile-logo {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-logo img {
    max-height: 40px;
    width: auto;
}

/* Sidebar Overlay */
.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 ease;
    pointer-events: none;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* Tablet and Mobile Sidebar */
@media (max-width: 1024px) {
    html, body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
        width: 100% !important;
        position: relative;
    }

    .mobile-header {
        display: flex;
        max-width: 100vw;
        width: 100%;
    }

    .sidebar-overlay {
        display: block;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 999;
        width: 280px !important;
        max-width: 85vw;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
        padding: 80px 15px 20px !important;
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }

    body.sidebar-open {
        overflow: hidden;
        overflow-x: hidden !important;
    }

    /* Mobile-friendly tables - All table types */
    table,
    .tasks-table,
    .users-table,
    .players-table,
    .fixtures-table,
    .cards-table,
    .meetings-table,
    .documents-table,
    .projects-table {
        display: block;
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box !important;
    }

    table thead,
    .tasks-table thead,
    .users-table thead,
    .players-table thead,
    .fixtures-table thead,
    .cards-table thead,
    .meetings-table thead,
    .documents-table thead,
    .projects-table thead {
        display: none;
    }

    table tbody,
    .tasks-table tbody,
    .users-table tbody,
    .players-table tbody,
    .fixtures-table tbody,
    .cards-table tbody,
    .meetings-table tbody,
    .documents-table tbody,
    .projects-table tbody {
        display: block;
        width: 100%;
    }

    table tr,
    .tasks-table tr,
    .users-table tr,
    .players-table tr,
    .fixtures-table tr,
    .cards-table tr,
    .meetings-table tr,
    .documents-table tr,
    .projects-table tr {
        display: block;
        width: 100%;
        margin-bottom: 15px;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        padding: 15px;
        background: white;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }

    table td,
    table th,
    .tasks-table td,
    .users-table td,
    .players-table td,
    .fixtures-table td,
    .cards-table td,
    .meetings-table td,
    .documents-table td,
    .projects-table td {
        display: block;
        width: 100%;
        text-align: left !important;
        padding: 8px 0;
        border: none;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    table td:before,
    .tasks-table td:before,
    .users-table td:before,
    .players-table td:before,
    .fixtures-table td:before,
    .cards-table td:before,
    .meetings-table td:before,
    .documents-table td:before,
    .projects-table td:before {
        content: attr(data-label) ": ";
        font-weight: 600;
        color: #2c3e50;
        display: inline-block;
        min-width: 120px;
        margin-right: 8px;
    }

    /* Mobile forms */
    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    .form-group {
        width: 100% !important;
        margin-bottom: 15px !important;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }

    .content-card {
        padding: 20px 15px !important;
        margin-bottom: 20px !important;
    }

    .page-header {
        padding: 20px 15px !important;
        margin-bottom: 20px !important;
    }

    .page-header h1 {
        font-size: 24px !important;
        line-height: 1.3;
    }

    .page-header p {
        font-size: 14px !important;
    }

    /* Stats grid */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    /* Buttons */
    .btn {
        width: 100%;
        margin-bottom: 10px;
        box-sizing: border-box;
        padding: 12px 20px !important;
    }

    .btn:last-child {
        margin-bottom: 0;
    }

    /* Button groups */
    .btn-group {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .btn-group .btn {
        width: 100%;
        margin: 0;
    }

    /* Select dropdowns */
    select {
        width: 100% !important;
        min-width: auto !important;
        max-width: 100% !important;
    }

    /* Prevent all horizontal scrolling */
    * {
        max-width: 100vw !important;
    }

    /* Override any max-width constraints */
    .links-grid,
    .projects-grid,
    .content-section,
    .form-grid,
    .stats-grid,
    .meetings-grid {
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Force single column for all grids on tablet and mobile */
    .meetings-grid {
        grid-template-columns: 1fr !important;
    }

    /* Grid layouts - Projects, Links, Tiles */
    .links-grid,
    .projects-grid,
    .tiles-grid,
    .cards-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
        max-width: 100% !important;
        width: 100% !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }

    .link-card,
    .project-card,
    .tile-card,
    .card-item {
        min-height: auto !important;
        padding: 20px 15px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .link-icon {
        font-size: 40px !important;
        margin-bottom: 10px !important;
    }

    .link-title {
        font-size: 16px !important;
    }

    .link-description {
        font-size: 12px !important;
    }

    /* Meeting cards */
    .meeting-card {
        width: 100% !important;
        margin-bottom: 15px !important;
    }

    /* Document cards */
    .document-card {
        width: 100% !important;
        margin-bottom: 15px !important;
    }

    /* Project detail sections */
    .project-section {
        width: 100% !important;
        margin-bottom: 20px !important;
    }

    /* Modals */
    .modal {
        width: 95% !important;
        max-width: 95% !important;
        margin: 10px auto !important;
        padding: 20px 15px !important;
    }

    .modal-content {
        padding: 15px !important;
    }

    .modal-header h2 {
        font-size: 20px !important;
    }

    /* Tabs */
    .tabs {
        flex-wrap: wrap;
        padding: 0 15px !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tab-button {
        padding: 12px 15px !important;
        font-size: 13px !important;
        white-space: nowrap;
    }

    /* Search bars */
    .search-bar {
        width: 100% !important;
        margin-bottom: 15px;
    }

    .search-bar input {
        width: 100% !important;
        box-sizing: border-box;
    }

    /* Text overflow */
    h1, h2, h3, h4, h5, h6 {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    p, span, div, td, th {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Images */
    img {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Calendar */
    .calendar-container {
        width: 100% !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .calendar {
        min-width: 100%;
    }

    /* Status cards */
    .status-card {
        width: 100% !important;
        margin-bottom: 15px !important;
    }

    /* Action buttons row */
    .action-buttons {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .action-buttons .btn {
        width: 100%;
        margin: 0;
    }

    /* File upload areas */
    .file-upload-area {
        width: 100% !important;
        padding: 20px 15px !important;
    }

    /* Activity feed */
    .activity-feed {
        width: 100% !important;
    }

    .activity-item {
        padding: 15px !important;
        margin-bottom: 10px !important;
    }

    /* Comments section */
    .comments-section {
        width: 100% !important;
    }

    .comment-item {
        padding: 15px !important;
        margin-bottom: 10px !important;
    }

    /* Messages section */
    .messages-section {
        width: 100% !important;
    }

    .message-item {
        padding: 15px !important;
        margin-bottom: 10px !important;
    }

    /* Badges */
    .badge {
        font-size: 11px !important;
        padding: 4px 8px !important;
    }

    /* Alerts */
    .alert {
        padding: 12px 15px !important;
        font-size: 14px !important;
        margin-bottom: 15px !important;
    }

    /* Welcome section */
    .welcome-section {
        padding: 20px 15px !important;
    }

    .welcome-section h1 {
        font-size: 24px !important;
    }

    /* Quick actions */
    .quick-actions {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    /* Filters */
    .filters {
        flex-direction: column !important;
        gap: 10px !important;
    }

    .filters select,
    .filters input {
        width: 100% !important;
    }

    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 5px;
    }

    .pagination a,
    .pagination span {
        padding: 8px 12px !important;
        font-size: 14px !important;
    }

    /* Tooltips and popovers */
    .tooltip,
    .popover {
        max-width: 90% !important;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .main-content {
        padding: 70px 10px 15px !important;
    }

    .content-card {
        padding: 15px 10px !important;
    }

    .page-header {
        padding: 15px 10px !important;
    }

    .page-header h1 {
        font-size: 20px !important;
    }

    .welcome-section {
        padding: 20px 15px !important;
    }

    .welcome-section h1 {
        font-size: 22px !important;
    }

    .link-card,
    .project-card,
    .tile-card {
        padding: 15px 10px !important;
        min-height: 140px !important;
    }

    .link-icon {
        font-size: 40px !important;
    }

    .link-title {
        font-size: 14px !important;
    }

    .link-description {
        font-size: 11px !important;
    }

    .btn {
        padding: 10px 15px !important;
        font-size: 14px !important;
    }

    .modal {
        width: 98% !important;
        padding: 15px 10px !important;
    }

    .modal-content {
        padding: 10px !important;
    }

    .tab-button {
        padding: 10px 12px !important;
        font-size: 12px !important;
    }

    .alert {
        padding: 10px 12px !important;
        font-size: 13px !important;
    }

    .badge {
        font-size: 10px !important;
        padding: 3px 6px !important;
    }
}

/* Extra small devices */
@media (max-width: 360px) {
    .main-content {
        padding: 65px 8px 12px !important;
    }

    .content-card {
        padding: 12px 8px !important;
    }

    .page-header {
        padding: 12px 8px !important;
    }

    .page-header h1 {
        font-size: 18px !important;
    }

    .link-card,
    .project-card,
    .tile-card {
        padding: 12px 8px !important;
        min-height: 120px !important;
    }

    .link-icon {
        font-size: 36px !important;
    }

    .btn {
        padding: 8px 12px !important;
        font-size: 13px !important;
    }
}

/* Landscape orientation on tablet and mobile */
@media (max-width: 1024px) and (orientation: landscape) {
    .main-content {
        padding: 60px 15px 15px !important;
    }

    .mobile-header {
        height: 50px;
    }

    .links-grid,
    .projects-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Hide PWA install banner on desktop (above 1024px) */
@media (min-width: 1025px) {
    #installBanner,
    #installButton {
        display: none !important;
    }
}

/* Ensure all content sections are constrained */
.content-section {
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

@media (max-width: 1024px) {
    .content-section {
        grid-template-columns: 1fr !important;
    }
}

/* Print styles */
@media print {
    .sidebar,
    .mobile-header,
    .sidebar-overlay {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }
}
