/**
 * ManiReports Plugin Styles
 * 
 * Responsive UI foundation with Bootstrap-compatible styling
 * 
 * @package     local_manireports
 * @copyright   2024 ManiReports
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

/* ========================================
   Dashboard Layout
   ======================================== */

.manireports-dashboard {
    padding: 20px 0;
}

.manireports-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

/* ========================================
   Widgets & Cards
   ======================================== */

.manireports-widget {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: box-shadow 0.3s ease;
}

.manireports-widget:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.manireports-widget-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: #333;
}

.manireports-widget-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: #0066cc;
    margin-bottom: 10px;
}

.manireports-widget-description {
    font-size: 0.9rem;
    color: #666;
}

/* ========================================
   Filters
   ======================================== */

.manireports-filters {
    margin-bottom: 20px;
}

.manireports-filters .card-body {
    padding: 15px;
}

.manireports-filters .form-control,
.manireports-filters .custom-select {
    font-size: 0.9rem;
}

.manireports-filters label {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 5px;
    color: #555;
}

/* ========================================
   Charts
   ======================================== */

.manireports-chart-container {
    position: relative;
    height: 300px;
    margin: 20px 0;
}

.manireports-chart-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.manireports-chart-error {
    padding: 20px;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    color: #721c24;
    text-align: center;
}

/* ========================================
   Tables
   ======================================== */

.manireports-table-wrapper {
    overflow-x: auto;
    margin: 20px 0;
}

.manireports-table {
    width: 100%;
    font-size: 0.9rem;
}

.manireports-table th {
    background: #f8f9fa;
    font-weight: 600;
    padding: 12px 8px;
    border-bottom: 2px solid #dee2e6;
}

.manireports-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #dee2e6;
}

.manireports-table tbody tr:hover {
    background: #f8f9fa;
}

/* ========================================
   Export Buttons
   ======================================== */

.manireports-export-buttons {
    margin: 15px 0;
}

.manireports-export-buttons .btn {
    margin-right: 10px;
    margin-bottom: 10px;
}

/* ========================================
   Loading States
   ======================================== */

.manireports-loading {
    text-align: center;
    padding: 40px;
}

.manireports-loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0066cc;
    border-radius: 50%;
    animation: manireports-spin 1s linear infinite;
}

@keyframes manireports-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========================================
   Notifications & Alerts
   ======================================== */

.manireports-alert {
    padding: 12px 20px;
    margin-bottom: 20px;
    border-radius: 4px;
    border-left: 4px solid;
}

.manireports-alert-info {
    background: #d1ecf1;
    border-color: #0c5460;
    color: #0c5460;
}

.manireports-alert-success {
    background: #d4edda;
    border-color: #155724;
    color: #155724;
}

.manireports-alert-warning {
    background: #fff3cd;
    border-color: #856404;
    color: #856404;
}

.manireports-alert-error {
    background: #f8d7da;
    border-color: #721c24;
    color: #721c24;
}

/* ========================================
   Responsive Design - Tablet
   ======================================== */

@media (max-width: 768px) {
    .manireports-dashboard-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 15px;
    }
    
    .manireports-widget {
        padding: 15px;
    }
    
    .manireports-widget-value {
        font-size: 2rem;
    }
    
    .manireports-chart-container {
        height: 250px;
    }
    
    .manireports-table {
        font-size: 0.85rem;
    }
    
    .manireports-table th,
    .manireports-table td {
        padding: 8px 6px;
    }
    
    .manireports-filters .col-md-3,
    .manireports-filters .col-md-2 {
        margin-bottom: 10px;
    }
}

/* ========================================
   Responsive Design - Mobile
   ======================================== */

@media (max-width: 576px) {
    .manireports-dashboard {
        padding: 10px 0;
    }
    
    .manireports-dashboard-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .manireports-widget {
        padding: 12px;
    }
    
    .manireports-widget-title {
        font-size: 1rem;
    }
    
    .manireports-widget-value {
        font-size: 1.8rem;
    }
    
    .manireports-chart-container {
        height: 200px;
    }
    
    .manireports-table-wrapper {
        margin: 10px -15px;
    }
    
    .manireports-table {
        font-size: 0.8rem;
    }
    
    .manireports-table th,
    .manireports-table td {
        padding: 6px 4px;
    }
    
    .manireports-export-buttons .btn {
        display: block;
        width: 100%;
        margin-right: 0;
    }
    
    .manireports-filters .row {
        margin: 0;
    }
    
    .manireports-filters .col-md-3,
    .manireports-filters .col-md-2 {
        padding: 0;
        margin-bottom: 10px;
    }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
    .manireports-export-buttons,
    .manireports-filters,
    .btn,
    .navbar,
    .footer {
        display: none !important;
    }
    
    .manireports-widget {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .manireports-table {
        font-size: 10pt;
    }
}

/* ========================================
   Accessibility
   ======================================== */

.manireports-widget:focus,
.manireports-table:focus {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

.manireports-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* ========================================
   Dark Mode Support (Optional)
   ======================================== */

@media (prefers-color-scheme: dark) {
    .manireports-widget {
        background: #2d2d2d;
        border-color: #444;
        color: #e0e0e0;
    }
    
    .manireports-widget-title {
        color: #e0e0e0;
    }
    
    .manireports-widget-value {
        color: #4da6ff;
    }
    
    .manireports-table th {
        background: #3d3d3d;
        color: #e0e0e0;
    }
    
    .manireports-table tbody tr:hover {
        background: #3d3d3d;
    }
}

/* ========================================
   Drill-Down Functionality
   ======================================== */

.manireports-drilldown-filters {
    position: relative;
    padding: 15px 20px;
    margin-bottom: 20px;
    background: #e7f3ff;
    border: 1px solid #b3d9ff;
    border-radius: 6px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.manireports-drilldown-filters strong {
    margin-right: 10px;
    color: #004085;
}

.manireports-drilldown-filters .badge {
    font-size: 0.9rem;
    padding: 6px 12px;
    background: #0066cc;
    color: #fff;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.manireports-drilldown-filters .badge button {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    margin: 0;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.manireports-drilldown-filters .badge button:hover {
    opacity: 1;
}

.manireports-drilldown-filters .btn {
    font-size: 0.85rem;
    padding: 4px 12px;
}

/* Loading overlay for drill-down transitions */
.manireports-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.manireports-loading-overlay .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Chart cursor for drill-down enabled charts */
.manireports-chart-drilldown canvas {
    cursor: pointer;
}

.manireports-chart-drilldown canvas:hover {
    opacity: 0.9;
}

/* Drill-down navigation breadcrumb */
.manireports-drilldown-breadcrumb {
    margin-bottom: 15px;
    padding: 10px 15px;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 0.9rem;
}

.manireports-drilldown-breadcrumb a {
    color: #0066cc;
    text-decoration: none;
    margin: 0 5px;
}

.manireports-drilldown-breadcrumb a:hover {
    text-decoration: underline;
}

.manireports-drilldown-breadcrumb .separator {
    color: #6c757d;
    margin: 0 5px;
}

/* Drill-down export buttons */
.manireports-drilldown-export {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #dee2e6;
}

.manireports-drilldown-export .btn {
    margin-right: 10px;
}

/* Responsive drill-down filters */
@media (max-width: 768px) {
    .manireports-drilldown-filters {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .manireports-drilldown-filters .badge {
        font-size: 0.85rem;
        padding: 5px 10px;
    }
    
    .manireports-drilldown-filters .btn {
        width: 100%;
        margin-top: 10px;
    }
}

@media (max-width: 576px) {
    .manireports-drilldown-filters {
        padding: 12px 15px;
    }
    
    .manireports-drilldown-filters .badge {
        font-size: 0.8rem;
        padding: 4px 8px;
    }
}

/* Premium Chart Styling */
.manireports-chart-container {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.card.shadow-sm {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
    border: none;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.card.shadow-sm:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12) !important;
    transform: translateY(-2px);
}

.card-title {
    font-weight: 600;
    color: #1f2937;
    font-size: 1.25rem;
}

.badge-info {
    background-color: #3b82f6;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.875rem;
}

/* Chart canvas styling */
#manireports-chart {
    cursor: pointer;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .card-body {
        padding: 1rem;
    }
    
    #manireports-chart {
        height: 350px !important;
    }
}
