/* Mobile Webapp Main CSS */
/* Import all required CSS libraries */

/* Local Poppins Font */
@import url('fonts.css');

/* DataTables CSS */
@import url('datatables.css');

/* Bootstrap 5 Latest */
@import url('bootstrap/bootstrap.min.css');

/* Toastr Notifications */
@import url('toastr.css');

/* Custom Mobile Webapp Styles */
:root {
    --primary-color: #007bff;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --mobile-padding: 15px;
    --mobile-margin: 10px;
}

/* Mobile Responsive Base Styles */
* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: #f5f5f5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-weight: 400;
    line-height: 1.6;
}

/* Padding for fixed navbar on larger screens */
@media (min-width: 768px) {
    body {
        padding-top: 56px; /* Account for fixed navbar height */
    }
}

/* Mobile Viewport Optimizations */
@media screen and (max-width: 768px) {
    body {
        font-size: 14px;
        line-height: 1.4;
        padding-top: 0; /* Remove padding on mobile for fixed navbar */
    }

    .container {
        padding-left: var(--mobile-padding);
        padding-right: var(--mobile-padding);
    }
}

/* Alert Styles - Success, Warning, Info, Danger */
.alert-custom {
    border-radius: 8px;
    border: none;
    margin-bottom: var(--mobile-margin);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.alert-success-custom {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.alert-warning-custom {
    background-color: #fff3cd;
    border-color: #ffeaa7;
    color: #856404;
}

.alert-info-custom {
    background-color: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
}

.alert-danger-custom {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

/* Modal Styles for Mobile */
.modal-custom {
    background-color: rgba(0,0,0,0.5);
}

.modal-custom .modal-dialog {
    margin: 10px;
    max-width: calc(100vw - 20px);
}

.modal-custom .modal-content {
    border-radius: 12px;
    border: none;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.modal-custom .modal-header {
    border-bottom: 1px solid #e9ecef;
    border-radius: 12px 12px 0 0;
    padding: 15px 20px;
}

.modal-custom .modal-body {
    padding: 20px;
}

.modal-custom .modal-footer {
    border-top: 1px solid #e9ecef;
    border-radius: 0 0 12px 12px;
    padding: 15px 20px;
}

/* Mobile Modal Optimizations */
@media screen and (max-width: 576px) {
    .modal-custom .modal-dialog {
        margin: 5px;
        max-width: calc(100vw - 10px);
    }

    .modal-custom .modal-body {
        padding: 15px;
    }
}

/* Loader Styles */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255,255,255,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

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

/* Spinner Styles */
.spinner-border-custom {
    width: 2rem;
    height: 2rem;
    border-width: 0.25em;
}

.spinner-border-custom.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.2em;
}

/* Form Validation Styles */
.form-group {
    margin-bottom: 1rem;
}

.form-control {
    border-radius: 8px;
    border: 1px solid #ced4da;
    padding: 0.75rem;
    font-size: 1rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,0.25);
}

.form-control.is-valid {
    border-color: var(--success-color);
    padding-right: calc(1.5em + 0.75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'%3e%3cpath fill='%2328a745' d='m2.3 6.73 4.47-4.47a.25.25 0 0 1 .35 0c.1.1.1.26 0 .35L2.3 7.42a.25.25 0 0 1-.35 0L.23 5.08a.25.25 0 0 1 0-.35c.1-.1.26-.1.35 0L2.3 6.73z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.form-control.is-invalid {
    border-color: var(--danger-color);
    padding-right: calc(1.5em + 0.75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23dc3545' viewBox='0 0 12 12'%3e%3cpath d='M6 11c.6 0 1-.4 1-1V6c0-.6-.4-1-1-1s-1 .4-1 1v4c0 .6.4 1 1 1zM5.1 3h1.8L6.9 2c-.2-.2-.5-.2-.7 0L5.1 3z'/%3e%3ccircle cx='6' cy='8.5' r='.5'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.invalid-feedback {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: var(--danger-color);
}

.valid-feedback {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: var(--success-color);
}

/* Button Styles */
.btn {
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-weight: 500;
    transition: all 0.15s ease-in-out;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-success {
    background-color: var(--success-color);
    border-color: var(--success-color);
}

.btn-warning {
    background-color: var(--warning-color);
    border-color: var(--warning-color);
    color: #212529;
}

.btn-danger {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
}

.btn-info {
    background-color: var(--info-color);
    border-color: var(--info-color);
}

/* Image Upload Styles */
.image-upload-container {
    position: relative;
    display: inline-block;
    width: 100%;
    max-width: 300px;
    margin-bottom: 1rem;
}

.image-upload-preview {
    width: 100%;
    height: 200px;
    border: 2px dashed #ced4da;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8f9fa;
    cursor: pointer;
    transition: all 0.3s ease;
    overflow: hidden;
}

.image-upload-preview:hover {
    border-color: var(--primary-color);
    background-color: #e9ecef;
}

.image-upload-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.image-upload-input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.image-upload-placeholder {
    text-align: center;
    color: #6c757d;
    font-size: 1.1rem;
}

.image-upload-placeholder i {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    display: block;
}

/* Mobile Optimizations */
@media screen and (max-width: 768px) {
    .image-upload-preview {
        height: 150px;
    }

    .btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.9rem;
    }

    .form-control {
        padding: 0.625rem;
        font-size: 0.9rem;
    }
}

/* Utility Classes */
.text-truncate-mobile {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mb-mobile {
    margin-bottom: var(--mobile-margin) !important;
}

.p-mobile {
    padding: var(--mobile-padding) !important;
}

/* Custom Animation Classes */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.slide-in-right {
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

/* Touch Friendly Elements */
.touch-target {
    min-height: 44px;
    min-width: 44px;
}

/* Status Indicators */
.status-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
}

.status-success {
    background-color: var(--success-color);
}

.status-warning {
    background-color: var(--warning-color);
}

.status-danger {
    background-color: var(--danger-color);
}

.status-info {
    background-color: var(--info-color);
}

/* Card Styles for Mobile */
.card {
    border-radius: 12px;
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: var(--mobile-margin);
}

.card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    border-radius: 12px 12px 0 0 !important;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

/* Badge Styles */
.badge {
    font-size: 0.75em;
    padding: 0.35em 0.65em;
    border-radius: 0.375rem;
}

/* Progress Bar Styles */
.progress {
    height: 8px;
    border-radius: 4px;
    background-color: #e9ecef;
}

.progress-bar {
    border-radius: 4px;
}

/* Toast Customizations for Mobile */
.toast {
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

@media screen and (max-width: 576px) {
    .toast {
        margin-bottom: 10px;
    }
}

/* Chart Responsive Styles */
.chart-container {
    position: relative;
    margin: auto;
    height: 300px;
    width: 100%;
}

@media screen and (max-width: 576px) {
    .chart-container {
        height: 200px;
        margin-bottom: 1rem;
    }
}

@media screen and (min-width: 577px) and (max-width: 768px) {
    .chart-container {
        height: 250px;
    }
}

/* Chart card responsive adjustments */
.chart-card .card-body {
    padding: 1rem;
}

@media screen and (max-width: 576px) {
    .chart-card .card-body {
        padding: 0.75rem;
    }

    .chart-card .card-header {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
}

/* Dashboard chart grid responsive */
@media screen and (max-width: 768px) {
    .chart-grid {
        gap: 1rem;
    }

    .chart-grid .col-xl-8,
    .chart-grid .col-lg-7 {
        margin-bottom: 1rem;
    }
}

/* Print Styles */
@media print {
    .no-print {
        display: none !important;
    }

    .print-only {
        display: block !important;
    }

    .chart-container {
        height: 200px !important;
        page-break-inside: avoid;
    }
}

/* Mobile Layout Fixes - Prevent Horizontal Scrolling */
@media (max-width: 991.98px) {
    /* Prevent horizontal scrolling on mobile */
    body, html {
        overflow-x: hidden !important;
        width: 100%;
        max-width: 100vw;
    }

    /* Ensure all containers respect viewport width */
    .container, .container-fluid {
        max-width: 100vw !important;
        overflow-x: hidden !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
    }

    /* Fix main content area */
    .main-content {
        margin-left: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }

    /* Ensure cards and components don't overflow */
    .card, .modal-dialog, .dropdown-menu {
        max-width: 100% !important;
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Fix table responsiveness */
    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Fix input fields */
    input, textarea, select {
        max-width: 100% !important;
        width: 100% !important;
    }

    /* Fix flex containers */
    .d-flex, .d-inline-flex {
        flex-wrap: wrap !important;
        max-width: 100% !important;
    }

    /* Fix button groups */
    .btn-group {
        flex-wrap: wrap !important;
    }

    /* Ensure images are responsive */
    img {
        max-width: 100% !important;
        height: auto !important;
    }
}

/* Extra Small Mobile Devices */
@media (max-width: 575.98px) {
    /* Reduce padding on very small screens */
    .container-fluid {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    /* Stack buttons vertically on very small screens */
    .btn-group-vertical {
        width: 100%;
    }

    .btn-group-vertical .btn {
        width: 100% !important;
        margin-bottom: 5px;
    }

    /* Adjust modal margins */
    .modal-dialog {
        margin: 5px !important;
    }

    /* Fix text overflow */
    .text-truncate {
        max-width: 100% !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
}
