/**
 * College CRM Frontend Styles
 * Student Portal, Course Catalog, Public Forms
 * 
 * @version 1.0.0
 */

/* ===== VARIABLES ===== */
:root {
    --crm-primary: #2563eb;
    --crm-primary-hover: #1d4ed8;
    --crm-success: #16a34a;
    --crm-warning: #f59e0b;
    --crm-error: #ef4444;
    --crm-gray-50: #f8fafc;
    --crm-gray-100: #f1f5f9;
    --crm-gray-200: #e2e8f0;
    --crm-gray-300: #cbd5e1;
    --crm-gray-500: #64748b;
    --crm-gray-700: #334155;
    --crm-gray-900: #0f172a;
    --crm-radius: 0.5rem;
    --crm-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --crm-transition: all 0.2s ease-in-out;
}

/* ===== STUDENT PORTAL ===== */
.college-crm-portal {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    direction: rtl;
}

.portal-header {
    background: linear-gradient(135deg, var(--crm-primary) 0%, var(--crm-primary-hover) 100%);
    color: white;
    padding: 2rem;
    border-radius: var(--crm-radius);
    margin-bottom: 2rem;
    text-align: center;
}

.portal-header h1 {
    margin: 0 0 0.5rem 0;
    font-size: 2rem;
    font-weight: 700;
}

.portal-header p {
    margin: 0;
    opacity: 0.9;
}

.portal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.portal-card {
    background: white;
    border: 1px solid var(--crm-gray-200);
    border-radius: var(--crm-radius);
    padding: 1.5rem;
    box-shadow: var(--crm-shadow);
    transition: var(--crm-transition);
}

.portal-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.portal-card h3 {
    color: var(--crm-gray-900);
    margin: 0 0 1rem 0;
    font-size: 1.25rem;
    font-weight: 600;
}

/* ===== COURSE CATALOG ===== */
.college-crm-courses {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    direction: rtl;
}

.courses-header {
    text-align: center;
    margin-bottom: 3rem;
}

.courses-header h1 {
    color: var(--crm-gray-900);
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.courses-header p {
    color: var(--crm-gray-500);
    font-size: 1.125rem;
    max-width: 600px;
    margin: 0 auto;
}

.courses-filters {
    background: white;
    padding: 1.5rem;
    border-radius: var(--crm-radius);
    margin-bottom: 2rem;
    box-shadow: var(--crm-shadow);
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
}

.courses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
}

.course-card {
    background: white;
    border: 1px solid var(--crm-gray-200);
    border-radius: var(--crm-radius);
    overflow: hidden;
    box-shadow: var(--crm-shadow);
    transition: var(--crm-transition);
}

.course-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}

.course-card-header {
    background: var(--crm-gray-50);
    padding: 1.5rem;
    border-bottom: 1px solid var(--crm-gray-200);
}

.course-card h3 {
    margin: 0 0 0.5rem 0;
    color: var(--crm-gray-900);
    font-size: 1.25rem;
    font-weight: 600;
}

.course-type {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
}

.course-type.frontal {
    background: var(--crm-success);
    color: white;
}

.course-type.digital {
    background: var(--crm-primary);
    color: white;
}

.course-type.hybrid {
    background: var(--crm-warning);
    color: white;
}

.course-card-body {
    padding: 1.5rem;
}

.course-card p {
    color: var(--crm-gray-500);
    margin: 0 0 1rem 0;
    line-height: 1.6;
}

.course-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    color: var(--crm-gray-500);
}

.course-price {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--crm-primary);
}

.course-card-footer {
    padding: 1.5rem;
    background: var(--crm-gray-50);
    border-top: 1px solid var(--crm-gray-200);
}

/* ===== FORMS ===== */
.college-crm-form {
    background: white;
    border: 1px solid var(--crm-gray-200);
    border-radius: var(--crm-radius);
    padding: 2rem;
    box-shadow: var(--crm-shadow);
    max-width: 600px;
    margin: 0 auto;
}

.college-crm-form h2 {
    color: var(--crm-gray-900);
    margin: 0 0 1.5rem 0;
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--crm-gray-700);
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--crm-gray-300);
    border-radius: var(--crm-radius);
    font-size: 1rem;
    transition: var(--crm-transition);
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--crm-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group.error input,
.form-group.error select,
.form-group.error textarea {
    border-color: var(--crm-error);
}

.form-error {
    color: var(--crm-error);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.form-success {
    color: var(--crm-success);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* ===== BUTTONS ===== */
.crm-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--crm-radius);
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: var(--crm-transition);
    text-align: center;
    justify-content: center;
}

.crm-btn-primary {
    background: var(--crm-primary);
    color: white;
}

.crm-btn-primary:hover {
    background: var(--crm-primary-hover);
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
}

.crm-btn-secondary {
    background: white;
    color: var(--crm-gray-700);
    border: 1px solid var(--crm-gray-300);
}

.crm-btn-secondary:hover {
    background: var(--crm-gray-50);
    color: var(--crm-gray-900);
    text-decoration: none;
}

.crm-btn-success {
    background: var(--crm-success);
    color: white;
}

.crm-btn-success:hover {
    background: #15803d;
    color: white;
    text-decoration: none;
}

.crm-btn-outline {
    background: transparent;
    color: var(--crm-primary);
    border: 2px solid var(--crm-primary);
}

.crm-btn-outline:hover {
    background: var(--crm-primary);
    color: white;
    text-decoration: none;
}

.crm-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* ===== ALERTS ===== */
.crm-alert {
    padding: 1rem 1.5rem;
    border-radius: var(--crm-radius);
    margin-bottom: 1.5rem;
    border-left: 4px solid;
}

.crm-alert-success {
    background: #f0fdf4;
    border-color: var(--crm-success);
    color: #15803d;
}

.crm-alert-error {
    background: #fef2f2;
    border-color: var(--crm-error);
    color: #dc2626;
}

.crm-alert-warning {
    background: #fffbeb;
    border-color: var(--crm-warning);
    color: #d97706;
}

.crm-alert-info {
    background: #eff6ff;
    border-color: var(--crm-primary);
    color: var(--crm-primary-hover);
}

/* ===== LOADING ===== */
.crm-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--crm-gray-200);
    border-top: 3px solid var(--crm-primary);
    border-radius: 50%;
    animation: crm-spin 1s linear infinite;
}

@keyframes crm-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.crm-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.crm-loading-content {
    text-align: center;
    color: var(--crm-gray-700);
}

.crm-loading-content .crm-loading {
    width: 40px;
    height: 40px;
    border-width: 4px;
    margin-bottom: 1rem;
}

/* ===== TABLES ===== */
.crm-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: var(--crm-radius);
    overflow: hidden;
    box-shadow: var(--crm-shadow);
}

.crm-table th {
    background: var(--crm-gray-50);
    color: var(--crm-gray-700);
    font-weight: 600;
    padding: 1rem;
    text-align: right;
    border-bottom: 1px solid var(--crm-gray-200);
}

.crm-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--crm-gray-100);
    color: var(--crm-gray-700);
}

.crm-table tr:hover td {
    background: var(--crm-gray-50);
}

.crm-table tr:last-child td {
    border-bottom: none;
}

/* ===== PROGRESS BAR ===== */
.crm-progress {
    width: 100%;
    height: 8px;
    background: var(--crm-gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.crm-progress-bar {
    height: 100%;
    background: var(--crm-primary);
    transition: width 0.3s ease;
}

.crm-progress-bar.success {
    background: var(--crm-success);
}

.crm-progress-bar.warning {
    background: var(--crm-warning);
}

.crm-progress-bar.error {
    background: var(--crm-error);
}

/* ===== BADGES ===== */
.crm-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.crm-badge-primary {
    background: var(--crm-primary);
    color: white;
}

.crm-badge-success {
    background: var(--crm-success);
    color: white;
}

.crm-badge-warning {
    background: var(--crm-warning);
    color: white;
}

.crm-badge-error {
    background: var(--crm-error);
    color: white;
}

.crm-badge-secondary {
    background: var(--crm-gray-200);
    color: var(--crm-gray-700);
}

/* ===== MODAL ===== */
.crm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: var(--crm-transition);
}

.crm-modal.show {
    opacity: 1;
    visibility: visible;
}

.crm-modal-content {
    background: white;
    border-radius: var(--crm-radius);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px rgba(0, 0, 0, 0.15);
    transform: scale(0.9);
    transition: var(--crm-transition);
}

.crm-modal.show .crm-modal-content {
    transform: scale(1);
}

.crm-modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--crm-gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.crm-modal-title {
    margin: 0;
    color: var(--crm-gray-900);
    font-size: 1.5rem;
    font-weight: 600;
}

.crm-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--crm-gray-500);
    padding: 0.5rem;
    border-radius: var(--crm-radius);
    transition: var(--crm-transition);
}

.crm-modal-close:hover {
    background: var(--crm-gray-100);
    color: var(--crm-gray-700);
}

.crm-modal-body {
    padding: 1.5rem;
}

.crm-modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--crm-gray-200);
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .college-crm-portal,
    .college-crm-courses {
        padding: 1rem;
    }
    
    .portal-grid,
    .courses-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .courses-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .course-meta {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
    
    .crm-modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    .crm-modal-header,
    .crm-modal-body,
    .crm-modal-footer {
        padding: 1rem;
    }
    
    .crm-modal-footer {
        flex-direction: column;
    }
    
    .college-crm-form {
        padding: 1rem;
        margin: 1rem;
    }
}

@media (max-width: 480px) {
    .portal-header,
    .courses-header {
        padding: 1rem;
    }
    
    .portal-header h1,
    .courses-header h1 {
        font-size: 1.5rem;
    }
    
    .portal-card,
    .course-card {
        margin-bottom: 1rem;
    }
    
    .course-card-header,
    .course-card-body,
    .course-card-footer {
        padding: 1rem;
    }
    
    .crm-table th,
    .crm-table td {
        padding: 0.5rem;
        font-size: 0.875rem;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .crm-btn,
    .crm-modal,
    .courses-filters {
        display: none !important;
    }
    
    .college-crm-portal,
    .college-crm-courses {
        padding: 0;
    }
    
    .portal-card,
    .course-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* ===== ACCESSIBILITY ===== */
.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;
}

/* Focus styles for keyboard navigation */
*:focus {
    outline: 2px solid var(--crm-primary);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --crm-gray-100: #e0e0e0;
        --crm-gray-200: #c0c0c0;
        --crm-gray-300: #a0a0a0;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}