/**
 * Gym Management System - Main Stylesheet
 * Mobile Responsive Design
 */

:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --dark-color: #212529;
    --light-color: #f8f9fa;
    --sidebar-width: 250px;
    --topbar-height: 60px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
}

/* Login Page */
.login-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-card {
    background: white;
    border-radius: 10px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--dark-color);
    color: white;
    z-index: 1000;
    transition: transform 0.3s ease;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    background: white;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.sidebar-header h4 {
    margin: 0;
    font-size: 1.2rem;
    color: black;
}

.sidebar-menu {
    list-style: none;
    padding: 10px 0;
    margin: 0;
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
}

.sidebar-menu li {
    margin: 0;
}

.sidebar-menu a {
    display: block;
    padding: 12px 20px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: all 0.3s;
    min-height: 44px;
    display: flex;
    align-items: center;
    border: none;
    outline: none;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    background: rgba(255,255,255,0.1);
    color: white;
    border: none;
    outline: none;
}

.sidebar-menu a i {
    margin-right: 10px;
    width: 20px;
}

.menu-divider {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 8px 20px;
    list-style: none;
    padding: 0;
}

.sidebar-footer {
    padding: 15px;
    background: rgba(0,0,0,0.2);
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: auto;
    flex-shrink: 0;
}

.sidebar-footer .btn {
    border: 1px solid rgba(255,255,255,0.3);
}

.sidebar-footer .btn:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.5);
}

.user-info {
    color: white;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.user-info strong {
    display: block;
    margin-bottom: 4px;
}

.user-info small {
    color: rgba(255,255,255,0.7);
    font-size: 0.85rem;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.navbar {
    height: var(--topbar-height);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Cards */
.card {
    border: none;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.stat-card {
    border-left: 4px solid var(--primary-color);
}

.stat-card .stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

.table {
    font-size: 0.9rem;
    width: 100%;
    margin-bottom: 0;
}

.table th {
    background-color: #f8f9fa;
    font-weight: 600;
    border-bottom: 2px solid #dee2e6;
    white-space: nowrap;
    padding: 12px 8px;
}

.table td {
    padding: 12px 8px;
    vertical-align: middle;
}

/* Action buttons in tables */
.table .btn-sm {
    min-height: 36px;
    min-width: 36px;
    padding: 6px 10px;
    margin: 2px;
}

.table .btn-group .btn {
    min-height: 36px;
}

/* Forms */
.form-control,
.form-select {
    border-radius: 4px;
    border: 1px solid #ced4da;
    padding: 8px 12px;
    font-size: 16px; /* Prevents iOS zoom on focus */
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Input groups */
.input-group {
    display: flex;
    flex-wrap: wrap;
}

.input-group .form-control,
.input-group .form-select {
    flex: 1;
    min-width: 0;
}

/* Buttons */
.btn {
    border-radius: 4px;
    padding: 8px 16px;
    font-weight: 500;
    transition: all 0.3s;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn i {
    margin-right: 5px;
}

/* Badges */
.badge {
    padding: 4px 8px;
    font-weight: 500;
    border-radius: 4px;
}

/* Sidebar Overlay (Mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 1000;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .container-fluid {
        padding: 10px !important;
    }
    
    .card {
        margin-bottom: 15px;
        border-radius: 8px;
    }
    
    .card-header {
        padding: 12px 15px;
        font-size: 0.95rem;
    }
    
    .card-body {
        padding: 15px;
    }
    
    .stat-card .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    
    .stat-card h3 {
        font-size: 1.5rem;
    }
    
    .stat-card h6 {
        font-size: 0.85rem;
    }
    
    /* Tables - Enhanced mobile */
    .table {
        font-size: 0.8rem;
    }
    
    .table th,
    .table td {
        padding: 8px 4px;
        font-size: 0.75rem;
    }
    
    .table th {
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    .table-responsive {
        border: none;
        margin: -15px;
        padding: 15px;
    }
    
    /* Buttons - Full width on mobile */
    .btn {
        width: 100%;
        margin-bottom: 10px;
        min-height: 44px;
        font-size: 16px;
    }
    
    .btn:last-child {
        margin-bottom: 0;
    }
    
    /* Button groups - Stack on mobile */
    .btn-group {
        display: flex;
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group .btn {
        width: 100%;
        margin-bottom: 8px;
        border-radius: 4px !important;
    }
    
    .btn-group .btn:last-child {
        margin-bottom: 0;
    }
    
    /* Action buttons in tables - Stack vertically */
    .table .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .table .btn-sm {
        width: 100%;
        margin: 2px 0;
    }
    
    /* Forms - Full width and larger */
    .form-control,
    .form-select {
        width: 100%;
        font-size: 16px;
        padding: 12px;
        margin-bottom: 10px;
    }
    
    .form-label {
        font-size: 14px;
        font-weight: 500;
        margin-bottom: 6px;
    }
    
    /* Input groups - Stack on mobile */
    .input-group {
        flex-direction: column;
        width: 100%;
    }
    
    .input-group .form-control,
    .input-group .form-select,
    .input-group .btn {
        width: 100%;
        border-radius: 4px;
        margin-bottom: 10px;
    }
    
    .input-group-text {
        width: 100%;
        border-radius: 4px;
        margin-bottom: 10px;
    }
    
    /* Search forms - Stack on mobile */
    .row.g-3 > [class*="col-"] {
        margin-bottom: 15px;
    }
    
    /* Single column layout on mobile */
    .row.g-3 > [class*="col-md-"],
    .row.g-3 > [class*="col-lg-"],
    .row.g-3 > [class*="col-xl-"] {
        width: 100%;
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    /* Navbar - Compact on mobile */
    .navbar {
        padding: 8px 10px;
        height: auto;
        min-height: 50px;
    }
    
    .navbar-brand {
        font-size: 0.9rem;
        padding: 0;
    }
    
    .navbar .btn {
        width: auto;
        min-width: 44px;
        padding: 8px 12px;
        margin: 0;
    }
    
    /* Larger toggle menu button on mobile */
    #toggleSidebar {
        font-size: 32px !important;
        padding: 14px 18px !important;
        min-width: 60px !important;
        min-height: 60px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    #toggleSidebar i {
        font-size: 32px !important;
        line-height: 1 !important;
    }
    
    /* Card headers - Stack buttons */
    .card-header {
        flex-direction: column;
        align-items: flex-start !important;
    }
    
    .card-header .btn {
        width: 100%;
        margin-top: 10px;
    }
    
    .card-header h5 {
        width: 100%;
        margin-bottom: 0;
    }
    
    /* Badges - Larger on mobile */
    .badge {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
    
    /* Alerts */
    .alert {
        padding: 12px 15px;
        font-size: 0.9rem;
    }
    
    /* Pagination - Full width */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .pagination .page-link {
        min-height: 44px;
        min-width: 44px;
        padding: 10px;
        font-size: 14px;
    }
    
    /* Stats grid - Single column */
    .row.g-3 .col-md-3,
    .row.g-3 .col-sm-6 {
        width: 100%;
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    /* Quick actions - 2 columns on mobile */
    .row.g-2 > [class*="col-md-3"] {
        width: 50%;
        flex: 0 0 50%;
        max-width: 50%;
        padding: 5px;
    }
    
    .row.g-2 .btn {
        width: 100%;
        font-size: 0.85rem;
        padding: 10px 8px;
    }
    
    /* POS Grid - 2 columns */
    .pos-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .pos-grid .card {
        margin-bottom: 0;
    }
    
    /* WhatsApp icon in mobile number column */
    .whatsapp-icon-mobile {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
        border-radius: 50%;
        background-color: rgba(37, 211, 102, 0.15);
        transition: all 0.2s;
        flex-shrink: 0;
        text-decoration: none !important;
    }
    
    .whatsapp-icon-mobile:hover {
        background-color: rgba(37, 211, 102, 0.25);
        transform: scale(1.05);
    }
    
    .whatsapp-icon-mobile:active {
        transform: scale(0.95);
        background-color: rgba(37, 211, 102, 0.3);
    }
    
    .whatsapp-icon-mobile .bi-whatsapp {
        font-size: 1.2rem;
        color: #25d366;
        line-height: 1;
    }
    
    .table td .mobile-number {
        word-break: break-all;
        font-size: 0.9rem;
        flex: 1;
        min-width: 0;
    }
    
    .table td .d-flex {
        gap: 8px;
        align-items: center;
        width: 100%;
    }
    
    /* Hide Action column on mobile */
    .table th.d-none,
    .table td.d-none {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: 20px;
    }
    
    .stat-card h3 {
        font-size: 1.3rem;
    }
    
    .stat-card h6 {
        font-size: 0.75rem;
    }
    
    .sidebar {
        width: 100%;
        max-width: 280px;
    }
    
    .navbar-brand {
        font-size: 0.85rem;
    }
    
    .container-fluid {
        padding: 8px !important;
    }
    
    .card-body {
        padding: 12px;
    }
    
    .table {
        font-size: 0.7rem;
    }
    
    .table th,
    .table td {
        padding: 6px 3px;
        font-size: 0.7rem;
    }
    
    /* Even smaller buttons on very small screens */
    .btn {
        font-size: 14px;
        padding: 10px 12px;
    }
    
    /* Quick actions - Single column on very small screens */
    .row.g-2 > [class*="col-md-3"] {
        width: 100%;
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    /* POS Grid - Single column on very small screens */
    .pos-grid {
        grid-template-columns: 1fr;
    }
    
    /* WhatsApp icon - Smaller on very small screens */
    .whatsapp-icon-mobile {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
    }
    
    .whatsapp-icon-mobile .bi-whatsapp {
        font-size: 1rem;
    }
    
    .table td .mobile-number {
        font-size: 0.85rem;
    }
    
    .table td .d-flex {
        gap: 6px;
    }
}

/* Show Action column on desktop */
@media (min-width: 768px) {
    .table th.d-md-table-cell,
    .table td.d-md-table-cell {
        display: table-cell !important;
    }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }
    
    .main-content {
        margin-left: 220px;
    }
}

/* Landscape Mode */
@media (max-width: 768px) and (orientation: landscape) {
    .sidebar-header {
        padding: 15px;
    }
    
    .sidebar-menu a {
        padding: 10px 20px;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .sidebar-menu a,
    .table tbody tr,
    .pagination .page-link,
    .card-header .btn,
    .navbar .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .form-control,
    .form-select,
    input[type="text"],
    input[type="email"],
    input[type="number"],
    input[type="tel"],
    input[type="date"],
    input[type="time"],
    textarea {
        font-size: 16px !important; /* Prevents iOS zoom */
        padding: 12px;
    }
    
    /* Larger touch targets */
    .table .btn-sm {
        min-height: 44px;
        min-width: 44px;
        padding: 10px;
    }
    
    /* Remove hover effects on touch devices */
    .btn:hover {
        transform: none;
    }
    
    /* Better tap feedback */
    .btn:active,
    .sidebar-menu a:active,
    .table tbody tr:active {
        opacity: 0.7;
        transform: scale(0.98);
    }
}

/* Dropdowns - Mobile friendly */
@media (max-width: 768px) {
    .dropdown-menu {
        width: 100%;
        max-width: 100%;
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    }
    
    .dropdown-item {
        padding: 12px 20px;
        min-height: 44px;
        font-size: 16px;
    }
}

/* Better spacing for mobile */
@media (max-width: 768px) {
    .mb-4 {
        margin-bottom: 1rem !important;
    }
    
    .mt-4 {
        margin-top: 1rem !important;
    }
    
    .p-4 {
        padding: 1rem !important;
    }
    
    /* List groups */
    .list-group-item {
        padding: 12px 15px;
        font-size: 0.9rem;
    }
    
    /* Breadcrumbs */
    .breadcrumb {
        font-size: 0.85rem;
        padding: 8px 0;
    }
    
    /* Tabs */
    .nav-tabs .nav-link {
        padding: 10px 15px;
        font-size: 0.9rem;
        min-height: 44px;
    }
    
    /* Progress bars */
    .progress {
        height: 20px;
    }
}

/* Utility classes for mobile */
@media (max-width: 768px) {
    .mobile-hide {
        display: none !important;
    }
    
    .mobile-show {
        display: block !important;
    }
    
    .mobile-full-width {
        width: 100% !important;
    }
    
    .mobile-text-center {
        text-align: center !important;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .navbar,
    .btn {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
}

/* Loading Spinner */
.spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3em;
}

/* Alert Styles */
.alert {
    border-radius: 4px;
    border: none;
    padding: 12px 16px;
}

/* Modal Styles */
.modal-dialog {
    margin: 20px auto;
}

.modal-content {
    border-radius: 8px;
    border: none;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

/* Bottom Sheet Modal (Mobile) */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100%;
        display: flex;
        align-items: flex-end;
    }
    
    .modal-content {
        border-radius: 16px 16px 0 0;
        height: auto;
        max-height: 90vh;
        display: flex;
        flex-direction: column;
        margin: 0;
        border: none;
    }
    
    .modal-header {
        border-bottom: 1px solid #dee2e6;
        padding: 15px 20px;
        flex-shrink: 0;
    }
    
    .modal-body {
        flex: 1;
        overflow-y: auto;
        padding: 20px;
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-footer {
        border-top: 1px solid #dee2e6;
        padding: 15px 20px;
        flex-shrink: 0;
    }
    
    .modal-footer .btn {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .modal-footer .btn:last-child {
        margin-bottom: 0;
    }
    
    /* Backdrop */
    .modal-backdrop {
        background-color: rgba(0, 0, 0, 0.5);
    }
}
