/**
 * Sneha Campus - UI Components Styles
 * Loading indicators, modals, and mobile responsiveness
 */

/* ===========================
   LOADING INDICATOR
   =========================== */
.global-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.global-loader.show {
    opacity: 1;
    pointer-events: all;
}

.loader-content {
    text-align: center;
    background: white;
    padding: 30px 50px;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.loader-text {
    color: #333;
    font-size: 16px;
    font-weight: 500;
    margin-top: 15px;
    margin-bottom: 0;
}

/* ===========================
   FORM VALIDATION STYLES
   =========================== */
.required-asterisk {
    color: #dc3545;
    font-weight: bold;
}

.form-control.is-invalid {
    border-color: #dc3545;
    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%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%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-valid {
    border-color: #28a745;
    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.73L.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%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;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: #dc3545;
}

/* ===========================
   CONFIRMATION DIALOG
   =========================== */
#confirmDialog .modal-header {
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
}

#confirmDialog .modal-title {
    font-weight: 600;
    color: #333;
}

#confirmDialog .modal-body p {
    font-size: 15px;
    color: #555;
    margin-bottom: 0;
}

#confirmDialog .modal-footer {
    border-top: 1px solid #dee2e6;
}

/* ===========================
   MOBILE RESPONSIVENESS
   =========================== */

/* Responsive Tables */
@media (max-width: 768px) {
    /* Make tables scrollable */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Stack cards vertically on mobile */
    .card {
        margin-bottom: 15px;
    }
    
    /* Adjust card body padding */
    .card-body {
        padding: 15px;
    }
    
    /* Smaller font sizes for mobile */
    .card-title {
        font-size: 18px;
    }
    
    /* Stack form elements */
    .form-row > .col,
    .form-row > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 10px;
    }
    
    /* Adjust button sizes */
    .btn {
        padding: 8px 12px;
        font-size: 14px;
    }
    
    .btn-sm {
        padding: 5px 10px;
        font-size: 12px;
    }
    
    /* Stack action buttons vertically */
    .btn-group {
        display: flex;
        flex-direction: column;
        gap: 5px;
    }
    
    .btn-group .btn {
        width: 100%;
        margin-left: 0 !important;
    }
}

/* Alternative table display for mobile */
@media (max-width: 576px) {
    .table-mobile-responsive {
        border: 0;
    }
    
    .table-mobile-responsive thead {
        display: none;
    }
    
    .table-mobile-responsive tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid #ddd;
        border-radius: 5px;
        background: white;
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    }
    
    .table-mobile-responsive td {
        display: flex;
        justify-content: space-between;
        padding: 10px;
        border: none;
        border-bottom: 1px solid #eee;
    }
    
    .table-mobile-responsive td:last-child {
        border-bottom: none;
    }
    
    .table-mobile-responsive td:before {
        content: attr(data-label);
        font-weight: bold;
        margin-right: 10px;
        color: #333;
    }
    
    /* Adjust dashboard cards */
    .dashboard-container h1 {
        font-size: 1.5em;
    }
    
    .easypie {
        width: 60px !important;
        height: 60px !important;
    }
    
    .easypie-data {
        font-size: 20px !important;
    }
}

/* ===========================
   RESPONSIVE SIDEBAR
   =========================== */
@media (max-width: 768px) {
    .page-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .page-sidebar.show {
        transform: translateX(0);
    }
    
    .content-wrapper {
        margin-left: 0 !important;
    }
    
    .page-brand {
        width: 100%;
    }
}

/* ===========================
   IMPROVED DASHBOARD CARDS
   =========================== */
.card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

/* ===========================
   RESPONSIVE CHARTS
   =========================== */
.chart-container {
    position: relative;
    margin: 20px auto;
}

@media (max-width: 768px) {
    .chart-container {
        padding: 15px;
    }
    
    .chart-title {
        font-size: 16px;
    }
    
    canvas {
        max-height: 250px !important;
    }
}

/* ===========================
   IMPROVED FORM LAYOUT
   =========================== */
.form-section {
    background: #f8f9fa;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 5px;
    border-left: 4px solid #5c6bc0;
}

.form-section-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #dee2e6;
}

/* ===========================
   ACTION BUTTONS
   =========================== */
.action-buttons {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

@media (max-width: 576px) {
    .action-buttons {
        flex-direction: column;
    }
    
    .action-buttons .btn {
        width: 100%;
    }
}

/* ===========================
   PAGINATION
   =========================== */
.pagination-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px 15px;
    background: #f8f9fa;
    border-radius: 5px;
}

@media (max-width: 576px) {
    .pagination-info {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
}

/* ===========================
   IMPROVED SEARCH BAR
   =========================== */
.search-bar {
    position: relative;
    margin-bottom: 20px;
}

.search-bar input {
    padding-right: 40px;
}

.search-bar .search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
}

/* ===========================
   FILTER PANEL
   =========================== */
.filter-panel {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.filter-panel .filter-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: flex-end;
}

@media (max-width: 768px) {
    .filter-panel .filter-row {
        flex-direction: column;
    }
    
    .filter-panel .form-group {
        width: 100%;
    }
}

/* ===========================
   LOADING SKELETON
   =========================== */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ===========================
   PRINT STYLES
   =========================== */
@media print {
    .no-print,
    .page-sidebar,
    .header,
    .btn,
    .action-buttons {
        display: none !important;
    }
    
    .content-wrapper {
        margin-left: 0 !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #ddd;
    }
}

/* ===========================
   ACCESSIBILITY IMPROVEMENTS
   =========================== */
.btn:focus,
.form-control:focus,
select:focus {
    outline: 2px solid #5c6bc0;
    outline-offset: 2px;
}

/* Skip to main content link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #5c6bc0;
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 100000;
}

.skip-link:focus {
    top: 0;
}

