/* Mobile-Optimized CSS for Committee Management System */

/* Base Mobile Styles */
@media (max-width: 768px) {
    /* Improved touch targets */
    .btn {
        min-height: 44px;
        padding: 12px 16px;
        font-size: 16px;
    }
    
    .btn-sm {
        min-height: 40px;
        padding: 10px 14px;
        font-size: 14px;
    }
    
    /* Better form controls for mobile */
    .form-control, .form-select {
        min-height: 44px;
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px 16px;
    }
    
    /* Improved navigation */
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    .navbar-nav .nav-link {
        padding: 12px 16px;
        font-size: 16px;
    }
    
    /* Better spacing for mobile */
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    /* Card improvements */
    .card {
        margin-bottom: 1rem;
        border-radius: 8px;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    /* Dashboard cards stack better on mobile */
    .dashboard-card {
        margin-bottom: 1rem;
    }
    
    .dashboard-card .card-body {
        text-align: center;
        padding: 1.5rem 1rem;
    }
    
    .dashboard-card h2 {
        font-size: 2rem;
        margin: 0.5rem 0;
    }
    
    .dashboard-card h5 {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }
}

/* Extra small devices (phones, less than 576px) */
@media (max-width: 575.98px) {
    /* Hide less important table columns on very small screens */
    .table-mobile-hide {
        display: none;
    }
    
    /* Stack table data vertically on very small screens */
    .table-responsive-stack {
        display: block;
    }
    
    .table-responsive-stack thead {
        display: none;
    }
    
    .table-responsive-stack tbody,
    .table-responsive-stack tr,
    .table-responsive-stack td {
        display: block;
        width: 100%;
    }
    
    .table-responsive-stack tr {
        border: 1px solid #dee2e6;
        margin-bottom: 1rem;
        padding: 1rem;
        border-radius: 8px;
        background: white;
    }
    
    .table-responsive-stack td {
        border: none;
        padding: 0.25rem 0;
        text-align: left;
    }
    
    .table-responsive-stack td:before {
        content: attr(data-label) ": ";
        font-weight: bold;
        color: #495057;
    }
    
    /* Better modal sizing */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    /* Improved form layouts */
    .form-row {
        margin-left: 0;
        margin-right: 0;
    }
    
    .form-row > .col,
    .form-row > [class*="col-"] {
        padding-left: 0;
        padding-right: 0;
        margin-bottom: 1rem;
    }
    
    /* Better button groups */
    .btn-group-vertical .btn {
        margin-bottom: 0.5rem;
    }
    
    /* Improved alerts */
    .alert {
        margin-bottom: 1rem;
        padding: 1rem;
        border-radius: 8px;
    }
    
    /* Better progress bars */
    .progress {
        height: 8px;
        margin: 0.5rem 0;
    }
    
    /* Improved badges */
    .badge {
        font-size: 0.75rem;
        padding: 0.375rem 0.5rem;
    }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) and (max-width: 991.98px) {
    /* Optimize for tablet view */
    .table-responsive {
        font-size: 0.9rem;
    }
    
    .btn {
        padding: 10px 14px;
    }
    
    .card-body {
        padding: 1.25rem;
    }
}

/* Touch-friendly improvements for all mobile devices */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn, .form-control, .form-select, .nav-link {
        min-height: 44px;
    }
    
    /* Remove hover effects that don't work on touch */
    .btn:hover,
    .nav-link:hover,
    .table-hover tbody tr:hover {
        transform: none;
        box-shadow: none;
    }
    
    /* Better focus states for touch */
    .btn:focus,
    .form-control:focus,
    .form-select:focus {
        box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.25);
        outline: none;
    }
}

/* Utility classes for mobile */
.mobile-only {
    display: none;
}

.desktop-only {
    display: block;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none;
    }
    
    .mobile-center {
        text-align: center;
    }
    
    .mobile-full-width {
        width: 100%;
    }
    
    .mobile-margin-bottom {
        margin-bottom: 1rem;
    }
    
    .mobile-padding {
        padding: 1rem;
    }
    
    .mobile-no-padding {
        padding: 0;
    }
}

/* Improved scrolling for mobile */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

/* Better loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Improved dropdown menus for mobile */
@media (max-width: 768px) {
    .dropdown-menu {
        border: none;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        border-radius: 8px;
    }
    
    .dropdown-item {
        padding: 12px 16px;
        font-size: 16px;
    }
}

/* Better spacing for dashboard elements */
@media (max-width: 768px) {
    .dashboard-stats .col-md-3,
    .dashboard-stats .col-md-4,
    .dashboard-stats .col-md-6 {
        margin-bottom: 1rem;
    }
    
    .dashboard-tools .card {
        margin-bottom: 1rem;
    }
    
    .dashboard-tools .card-body {
        padding: 1rem;
        text-align: center;
    }
}

/* Improved search and filter controls */
@media (max-width: 768px) {
    .search-controls {
        margin-bottom: 1rem;
    }

    .search-controls .form-control {
        margin-bottom: 0.5rem;
    }

    .filter-controls {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Mobile-specific table improvements */
@media (max-width: 768px) {
    /* Card-based table layout for mobile */
    .mobile-table-cards .table {
        display: none;
    }

    .mobile-table-cards .mobile-card {
        display: block;
        background: white;
        border: 1px solid #dee2e6;
        border-radius: 8px;
        margin-bottom: 1rem;
        padding: 1rem;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }

    .mobile-card-header {
        font-weight: bold;
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
        color: #495057;
        border-bottom: 1px solid #dee2e6;
        padding-bottom: 0.5rem;
    }

    .mobile-card-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.25rem 0;
        border-bottom: 1px solid #f8f9fa;
    }

    .mobile-card-row:last-child {
        border-bottom: none;
    }

    .mobile-card-label {
        font-weight: 600;
        color: #6c757d;
        font-size: 0.9rem;
    }

    .mobile-card-value {
        text-align: right;
        flex: 1;
        margin-left: 1rem;
    }

    .mobile-card-actions {
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid #dee2e6;
        display: flex;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .mobile-card-actions .btn {
        flex: 1;
        min-width: 120px;
    }
}

/* Enhanced navigation for mobile */
@media (max-width: 768px) {
    .navbar-collapse {
        background: rgba(0,0,0,0.95);
        margin-top: 1rem;
        border-radius: 8px;
        padding: 1rem;
    }

    .navbar-nav .nav-item {
        margin-bottom: 0.5rem;
    }

    .navbar-nav .nav-link {
        border-radius: 6px;
        transition: background-color 0.2s;
    }

    .navbar-nav .nav-link:hover,
    .navbar-nav .nav-link.active {
        background-color: rgba(255,255,255,0.1);
    }

    /* Improved navbar toggler */
    .navbar-toggler {
        border: none;
        padding: 8px 12px;
    }

    .navbar-toggler:focus {
        box-shadow: none;
    }
}

/* Mobile-optimized modals */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 1rem;
        max-width: calc(100% - 2rem);
    }

    .modal-content {
        border-radius: 12px;
    }

    .modal-header {
        padding: 1rem 1.5rem;
        border-bottom: 1px solid #dee2e6;
    }

    .modal-body {
        padding: 1.5rem;
        max-height: 70vh;
        overflow-y: auto;
    }

    .modal-footer {
        padding: 1rem 1.5rem;
        border-top: 1px solid #dee2e6;
        flex-direction: column;
        gap: 0.5rem;
    }

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

    .modal-footer .btn + .btn {
        margin-top: 0.5rem;
    }
}

/* Improved form layouts for mobile */
@media (max-width: 768px) {
    .form-floating {
        margin-bottom: 1rem;
    }

    .input-group {
        flex-direction: column;
    }

    .input-group .form-control,
    .input-group .btn {
        border-radius: 6px;
        margin-bottom: 0.5rem;
    }

    .input-group .btn {
        margin-bottom: 0;
    }

    /* Better checkbox and radio styling */
    .form-check {
        padding-left: 2rem;
        margin-bottom: 1rem;
    }

    .form-check-input {
        width: 1.25rem;
        height: 1.25rem;
        margin-left: -2rem;
    }

    .form-check-label {
        font-size: 1rem;
        line-height: 1.5;
    }
}

/* Touch-friendly interactions */
.mobile-device .btn {
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.mobile-device .btn:active {
    transform: scale(0.95);
}

/* Swipe animations */
.swipe-left {
    animation: swipeLeft 0.3s ease;
}

.swipe-right {
    animation: swipeRight 0.3s ease;
}

@keyframes swipeLeft {
    0% { transform: translateX(0); }
    50% { transform: translateX(-10px); }
    100% { transform: translateX(0); }
}

@keyframes swipeRight {
    0% { transform: translateX(0); }
    50% { transform: translateX(10px); }
    100% { transform: translateX(0); }
}

/* Mobile search enhancements */
.mobile-search-wrapper {
    position: relative;
}

.mobile-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    pointer-events: none;
    z-index: 2;
}

.mobile-search-wrapper input {
    padding-left: 40px;
    padding-right: 40px;
}

.mobile-clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: #6c757d;
    z-index: 2;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-clear-btn:hover {
    background-color: #f8f9fa;
    color: #495057;
}

/* Scroll indicators for tables */
.table-responsive.has-scroll {
    position: relative;
}

.scroll-indicator {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    z-index: 10;
    pointer-events: none;
}

/* Loading states */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

.btn.loading {
    position: relative;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    margin: auto;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Improved touch targets */
@media (max-width: 768px) {
    .table td, .table th {
        padding: 12px 8px;
    }

    .dropdown-item {
        padding: 12px 16px;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .form-check {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

/* Enhanced card interactions */
.mobile-card {
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    cursor: pointer;
}

.mobile-card:active {
    transform: scale(0.98);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Better focus states for accessibility */
.form-control:focus,
.form-select:focus,
.btn:focus {
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.25);
    border-color: #86b7fe;
}

/* Improved alert styling for mobile */
@media (max-width: 768px) {
    .alert {
        border-radius: 8px;
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .alert-heading {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }
}

/* Modern Member Dashboard Styles */
.bg-gradient {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
}

.card {
    border-radius: 12px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1) !important;
}

.card-body {
    border-radius: 12px;
}

/* Modern stat cards */
.stat-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 10px;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.stat-card .stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.5rem;
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.stat-card .stat-label {
    font-size: 0.9rem;
    color: #6c757d;
    font-weight: 500;
}

/* Progress bars */
.progress {
    border-radius: 10px;
    background-color: #f8f9fa;
}

.progress-bar {
    border-radius: 10px;
    transition: width 0.6s ease;
}

/* Badge improvements */
.badge {
    border-radius: 8px;
    font-weight: 500;
    padding: 0.5rem 1rem;
}

/* Modern alerts */
.alert {
    border: none;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.alert-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    color: #856404;
}

.alert-danger {
    background: linear-gradient(135deg, #f8d7da 0%, #fab1a0 100%);
    color: #721c24;
}

.alert-success {
    background: linear-gradient(135deg, #d1edff 0%, #74b9ff 100%);
    color: #155724;
}

/* Mobile optimizations for member dashboard */
@media (max-width: 768px) {
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .card-body {
        padding: 1.5rem !important;
    }

    .stat-card {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .stat-card .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }

    .stat-card .stat-value {
        font-size: 1.4rem;
    }

    .h3 {
        font-size: 1.5rem;
    }

    .h4 {
        font-size: 1.2rem;
    }

    .h5 {
        font-size: 1.1rem;
    }

    /* Better spacing for mobile */
    .row.g-4 {
        --bs-gutter-x: 1rem;
        --bs-gutter-y: 1rem;
    }

    .mb-4 {
        margin-bottom: 1.5rem !important;
    }

    .p-4 {
        padding: 1.5rem !important;
    }
}

/* Extra small devices */
@media (max-width: 576px) {
    .card-body {
        padding: 1rem !important;
    }

    .p-4 {
        padding: 1rem !important;
    }

    .stat-card {
        padding: 0.75rem;
    }

    .bg-gradient .card-body {
        padding: 1.5rem !important;
    }
}

/* Animation for loading states */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fadeInUp 0.5s ease-out;
}

.card:nth-child(2) {
    animation-delay: 0.1s;
}

.card:nth-child(3) {
    animation-delay: 0.2s;
}

.card:nth-child(4) {
    animation-delay: 0.3s;
}

/* Improved button styles */
.btn {
    border-radius: 8px;
    font-weight: 500;
    padding: 0.75rem 1.5rem;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn-outline-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3);
}
