/**
 * MedEx Smart Supplements Enhanced - Main Styles
 * Modern, responsive CSS for the enhanced plugin
 */

/* CSS Variables for consistent theming */
:root {
    --medex-primary: #667eea;
    --medex-secondary: #764ba2;
    --medex-accent: #00d4aa;
    --medex-success: #28a745;
    --medex-warning: #ffc107;
    --medex-error: #dc3545;
    --medex-info: #17a2b8;
    
    --medex-text-primary: #333;
    --medex-text-secondary: #666;
    --medex-text-muted: #999;
    
    --medex-bg-primary: #ffffff;
    --medex-bg-secondary: #f8f9fa;
    --medex-bg-dark: #343a40;
    
    --medex-border: #e1e5e9;
    --medex-border-light: #f0f0f0;
    
    --medex-shadow: 0 4px 15px rgba(0,0,0,0.1);
    --medex-shadow-hover: 0 8px 25px rgba(0,0,0,0.15);
    
    --medex-radius: 8px;
    --medex-radius-lg: 16px;
    --medex-radius-xl: 24px;
    
    --medex-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    --medex-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Global Styles */
.medex-container {
    font-family: var(--medex-font-family);
    line-height: 1.6;
    color: var(--medex-text-primary);
}

.medex-container * {
    box-sizing: border-box;
}

/* Utility Classes */
.medex-text-center { text-align: center; }
.medex-text-left { text-align: left; }
.medex-text-right { text-align: right; }

.medex-text-primary { color: var(--medex-primary); }
.medex-text-secondary { color: var(--medex-text-secondary); }
.medex-text-muted { color: var(--medex-text-muted); }
.medex-text-success { color: var(--medex-success); }
.medex-text-warning { color: var(--medex-warning); }
.medex-text-error { color: var(--medex-error); }

.medex-bg-primary { background-color: var(--medex-bg-primary); }
.medex-bg-secondary { background-color: var(--medex-bg-secondary); }
.medex-bg-gradient { background: linear-gradient(135deg, var(--medex-primary), var(--medex-secondary)); }

.medex-shadow { box-shadow: var(--medex-shadow); }
.medex-shadow-hover { box-shadow: var(--medex-shadow-hover); }

.medex-rounded { border-radius: var(--medex-radius); }
.medex-rounded-lg { border-radius: var(--medex-radius-lg); }
.medex-rounded-xl { border-radius: var(--medex-radius-xl); }

.medex-transition { transition: var(--medex-transition); }

/* Spacing Utilities */
.medex-m-0 { margin: 0; }
.medex-m-1 { margin: 0.5rem; }
.medex-m-2 { margin: 1rem; }
.medex-m-3 { margin: 1.5rem; }
.medex-m-4 { margin: 2rem; }

.medex-p-0 { padding: 0; }
.medex-p-1 { padding: 0.5rem; }
.medex-p-2 { padding: 1rem; }
.medex-p-3 { padding: 1.5rem; }
.medex-p-4 { padding: 2rem; }

/* Button Styles */
.medex-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: none;
    border-radius: var(--medex-radius);
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: var(--medex-transition);
    position: relative;
    overflow: hidden;
    min-height: 44px;
}

.medex-btn:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.medex-btn:hover:before {
    left: 100%;
}

.medex-btn-primary {
    background: linear-gradient(135deg, var(--medex-primary), var(--medex-secondary));
    color: white;
}

.medex-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.medex-btn-secondary {
    background: var(--medex-bg-secondary);
    color: var(--medex-text-primary);
    border: 2px solid var(--medex-border);
}

.medex-btn-secondary:hover {
    background: var(--medex-primary);
    color: white;
    border-color: var(--medex-primary);
}

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

.medex-btn-warning {
    background: var(--medex-warning);
    color: var(--medex-text-primary);
}

.medex-btn-error {
    background: var(--medex-error);
    color: white;
}

.medex-btn-lg {
    padding: 16px 32px;
    font-size: 18px;
    border-radius: 25px;
}

.medex-btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

.medex-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.medex-btn.loading {
    position: relative;
    color: transparent;
}

.medex-btn.loading:after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: medex-spin 1s linear infinite;
    color: white;
}

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

/* Form Styles */
.medex-form-group {
    margin-bottom: 1.5rem;
}

.medex-form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--medex-text-primary);
}

.medex-form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--medex-border);
    border-radius: var(--medex-radius);
    font-size: 16px;
    transition: var(--medex-transition);
    background: var(--medex-bg-primary);
}

.medex-form-control:focus {
    outline: none;
    border-color: var(--medex-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.medex-form-control.field-error {
    border-color: var(--medex-error);
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.medex-form-text {
    font-size: 14px;
    color: var(--medex-text-secondary);
    margin-top: 0.25rem;
}

.medex-form-error {
    color: var(--medex-error);
    font-size: 14px;
    margin-top: 0.25rem;
}

/* Card Styles */
.medex-card {
    background: var(--medex-bg-primary);
    border-radius: var(--medex-radius-lg);
    box-shadow: var(--medex-shadow);
    overflow: hidden;
    transition: var(--medex-transition);
}

.medex-card:hover {
    box-shadow: var(--medex-shadow-hover);
    transform: translateY(-4px);
}

.medex-card-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--medex-border-light);
    background: var(--medex-bg-secondary);
}

.medex-card-body {
    padding: 1.5rem;
}

.medex-card-footer {
    padding: 1rem 1.5rem;
    background: var(--medex-bg-secondary);
    border-top: 1px solid var(--medex-border-light);
}

/* Grid System */
.medex-row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -15px;
}

.medex-col {
    flex: 1;
    padding: 0 15px;
}

.medex-col-auto {
    flex: 0 0 auto;
}

.medex-col-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
.medex-col-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
.medex-col-3 { flex: 0 0 25%; max-width: 25%; }
.medex-col-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
.medex-col-6 { flex: 0 0 50%; max-width: 50%; }
.medex-col-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
.medex-col-9 { flex: 0 0 75%; max-width: 75%; }
.medex-col-12 { flex: 0 0 100%; max-width: 100%; }

/* Notification Styles */
#medex-notifications {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    max-width: 400px;
}

.medex-notification {
    padding: 16px 20px;
    margin-bottom: 10px;
    border-radius: var(--medex-radius);
    color: white;
    font-weight: 500;
    cursor: pointer;
    box-shadow: var(--medex-shadow);
    position: relative;
    overflow: hidden;
}

.medex-notification:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: rgba(255,255,255,0.3);
}

.medex-notification-success {
    background: var(--medex-success);
}

.medex-notification-warning {
    background: var(--medex-warning);
    color: var(--medex-text-primary);
}

.medex-notification-error {
    background: var(--medex-error);
}

.medex-notification-info {
    background: var(--medex-info);
}

/* Loading Spinner */
.medex-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--medex-border-light);
    border-top: 4px solid var(--medex-primary);
    border-radius: 50%;
    animation: medex-spin 1s linear infinite;
    margin: 0 auto;
}

/* Badge Styles */
.medex-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.medex-badge-primary {
    background: var(--medex-primary);
    color: white;
}

.medex-badge-success {
    background: var(--medex-success);
    color: white;
}

.medex-badge-warning {
    background: var(--medex-warning);
    color: var(--medex-text-primary);
}

.medex-badge-error {
    background: var(--medex-error);
    color: white;
}

.medex-badge-secondary {
    background: var(--medex-bg-secondary);
    color: var(--medex-text-secondary);
    border: 1px solid var(--medex-border);
}

/* Progress Bar */
.medex-progress {
    height: 8px;
    background: var(--medex-bg-secondary);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.medex-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--medex-primary), var(--medex-accent));
    transition: width 0.5s ease;
    position: relative;
    overflow: hidden;
}

.medex-progress-bar:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: medex-shimmer 2s infinite;
}

@keyframes medex-shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Modal Styles */
.medex-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
}

.medex-modal-content {
    background-color: var(--medex-bg-primary);
    margin: 5% auto;
    padding: 0;
    border-radius: var(--medex-radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    animation: medex-modal-in 0.3s ease-out;
}

@keyframes medex-modal-in {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.medex-modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--medex-border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.medex-modal-title {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.medex-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--medex-text-secondary);
    padding: 5px;
    border-radius: var(--medex-radius);
    transition: var(--medex-transition);
}

.medex-modal-close:hover {
    background: var(--medex-bg-secondary);
    color: var(--medex-text-primary);
}

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

.medex-modal-footer {
    padding: 20px;
    border-top: 1px solid var(--medex-border-light);
    background: var(--medex-bg-secondary);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Table Styles */
.medex-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    background: var(--medex-bg-primary);
}

.medex-table th,
.medex-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--medex-border-light);
}

.medex-table th {
    background: var(--medex-bg-secondary);
    font-weight: 600;
    color: var(--medex-text-primary);
}

.medex-table tr:hover {
    background: var(--medex-bg-secondary);
}

.medex-table-striped tr:nth-child(even) {
    background: var(--medex-bg-secondary);
}

/* Alert Styles */
.medex-alert {
    padding: 16px 20px;
    margin-bottom: 1rem;
    border-radius: var(--medex-radius);
    border-left: 4px solid;
    position: relative;
}

.medex-alert-success {
    background: rgba(40, 167, 69, 0.1);
    border-color: var(--medex-success);
    color: #155724;
}

.medex-alert-warning {
    background: rgba(255, 193, 7, 0.1);
    border-color: var(--medex-warning);
    color: #856404;
}

.medex-alert-error {
    background: rgba(220, 53, 69, 0.1);
    border-color: var(--medex-error);
    color: #721c24;
}

.medex-alert-info {
    background: rgba(23, 162, 184, 0.1);
    border-color: var(--medex-info);
    color: #0c5460;
}

/* Responsive Design */
@media (max-width: 768px) {
    .medex-row {
        margin: 0 -10px;
    }
    
    .medex-col {
        padding: 0 10px;
    }
    
    .medex-col-1,
    .medex-col-2,
    .medex-col-3,
    .medex-col-4,
    .medex-col-6,
    .medex-col-8,
    .medex-col-9 {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 1rem;
    }
    
    .medex-btn {
        width: 100%;
        justify-content: center;
    }
    
    .medex-btn-sm {
        width: auto;
        display: inline-flex;
    }
    
    #medex-notifications {
        left: 10px;
        right: 10px;
        max-width: none;
    }
    
    .medex-modal-content {
        margin: 10% auto;
        width: 95%;
    }
    
    .medex-table {
        font-size: 14px;
    }
    
    .medex-table th,
    .medex-table td {
        padding: 8px 12px;
    }
}

@media (max-width: 480px) {
    .medex-card-body,
    .medex-card-header,
    .medex-card-footer {
        padding: 1rem;
    }
    
    .medex-modal-body,
    .medex-modal-header,
    .medex-modal-footer {
        padding: 15px;
    }
    
    .medex-btn {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .medex-btn-lg {
        padding: 14px 28px;
        font-size: 16px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --medex-text-primary: #e9ecef;
        --medex-text-secondary: #adb5bd;
        --medex-text-muted: #6c757d;
        
        --medex-bg-primary: #212529;
        --medex-bg-secondary: #343a40;
        --medex-bg-dark: #495057;
        
        --medex-border: #495057;
        --medex-border-light: #343a40;
    }
}

/* Print Styles */
@media print {
    .medex-btn,
    .medex-modal,
    #medex-notifications {
        display: none !important;
    }
    
    .medex-card {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .medex-table {
        border: 1px solid #ccc;
    }
    
    .medex-table th,
    .medex-table td {
        border: 1px solid #ccc;
    }
}

/* Accessibility Improvements */
.medex-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;
}

.medex-btn:focus,
.medex-form-control:focus {
    outline: 2px solid var(--medex-primary);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .medex-btn {
        border: 2px solid;
    }
    
    .medex-card {
        border: 2px solid var(--medex-border);
    }
    
    .medex-form-control {
        border-width: 3px;
    }
}
