/**
 * Design System - Components
 * Intranet Lycée du Pays de Bray
 * 
 * Composants réutilisables : boutons, cards, badges, formulaires, etc.
 */

/* =============================================
   BOUTONS
   ============================================= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    background: var(--primary);
    color: var(--text-inverse) !important;
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all var(--transition-normal);
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    font-family: inherit;
    box-shadow: var(--shadow-primary);
}

.btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(var(--primary), 0.4);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--primary) !important;
    border: 1px solid var(--border-main);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background: var(--primary-200);
    border-color: var(--primary-400);
    color: var(--primary-800) !important;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-success {
    background: var(--success);
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    background: var(--success-dark);
    box-shadow: 0 6px 8px -1px rgba(16, 185, 129, 0.4);
}

.btn-danger {
    background: var(--error);
    box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: var(--error-dark);
}

.btn-large {
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    justify-content: center;
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    transition: all var(--transition-normal);
    /* Optical alignment adjustment to align text with typical left margins if needed, 
       but keeping it 0 for general usage is safer. 
       Can be overridden if inside specific headers. */
}

.btn-back:hover {
    color: var(--primary-800);
    background: var(--primary-200);
    transform: translateX(-4px);
    border: 1px solid var(--primary-300);
    /* Subtle feedback direction 'back' */
}

.btn-back i {
    width: 20px;
    height: 20px;
}

/* Navigation Buttons (Tabs) */
.btn-nav {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    background: var(--bg-card);
    color: var(--text-muted);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    text-decoration: none;
    font-weight: 600;
    transition: all var(--transition-normal);
}

.btn-nav:hover {
    background: var(--primary-100);
    color: var(--primary-700);
    transform: translateY(-2px);
}

.btn-nav.active {
    background: var(--primary);
    color: var(--text-inverse);
    box-shadow: var(--shadow-primary);
}

/* =============================================
   CARDS
   ============================================= */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--bg-glass-border);
    transition: all var(--transition-normal);
}

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

.card-clickable {
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.card-clickable:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
}

/* Widget Cards (sidebar) */
.widget-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--bg-glass-border);
}

/* Tool Cards */
.tool-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-decoration: none;
    color: var(--text-main);
    transition: all var(--transition-slow);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--bg-glass-border);
    position: relative;
    overflow: hidden;
}

.tool-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: var(--primary);
}

.tool-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.tool-info h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-main);
}

.tool-info p {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
}

/* Quick Access Cards */
.quick-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    text-align: center;
    text-decoration: none;
    color: var(--text-main);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-slow);
    border: 1px solid var(--bg-glass-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.quick-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
    border-color: var(--primary);
}

.quick-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
    transition: transform var(--transition-slow);
}

.quick-card:hover .quick-card-icon {
    transform: scale(1.1) rotate(5deg);
}

.quick-card-title {
    font-weight: 600;
    font-size: 0.9rem;
}

/* =============================================
   BADGES
   ============================================= */
.badge {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-admin {
    background: var(--error-light);
    color: var(--error);
}

.badge-teacher {
    background: var(--success-light);
    color: var(--success-dark);
}

.badge-student {
    background: var(--info-light);
    color: var(--info-dark);
}

.badge-staff {
    background: var(--warning-light);
    color: var(--warning-dark);
}

/* =============================================
   FORMULAIRES
   ============================================= */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-main);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    color: var(--text-main);
    outline: none;
    transition: all var(--transition-normal);
    font-family: inherit;
}

.form-input:focus {
    border-color: var(--primary);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-input::placeholder {
    color: var(--text-light);
}

.form-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* File Input */
input[type="file"].form-input {
    padding: 1rem;
    border: 2px dashed var(--border-main);
    cursor: pointer;
}

input[type="file"].form-input:hover {
    border-color: var(--primary);
}

/* =============================================
   TABLES
   ============================================= */
.table-container {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

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

.table th {
    background: var(--bg-card-hover);
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table tbody tr:hover {
    background: var(--bg-card-hover);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* =============================================
   ALERTS
   ============================================= */
.alert {
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.alert-success {
    background: var(--success-light);
    color: var(--success-dark);
    border: 1px solid var(--success);
}

.alert-error {
    background: var(--error-light);
    color: var(--error-dark);
    border: 1px solid var(--error);
}

.alert-warning {
    background: var(--warning-light);
    color: var(--warning-dark);
    border: 1px solid var(--warning);
}

.alert-info {
    background: var(--info-light);
    color: var(--info-dark);
    border: 1px solid var(--info);
}

/* =============================================
   SECTION TITLES
   ============================================= */
.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* =============================================
   GRIDS
   ============================================= */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.grid-auto {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.quick-access-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

/* =============================================
   UTILITIES
   ============================================= */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
}

.mb-0 {
    margin-bottom: 0;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mb-3 {
    margin-bottom: 1.5rem;
}

.mb-4 {
    margin-bottom: 2rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mt-4 {
    margin-top: 2rem;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 768px) {

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    header {
        padding: 0.75rem 1rem;
    }

    main {
        padding: 0 1rem;
    }
}

/* =============================================
   WIDGETS
   ============================================= */
.widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.widget-header-title-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.widget-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.widget-link {
    color: var(--primary);
    font-size: 0.85rem;
    text-decoration: none;
    font-weight: 500;
}

.widget-link:hover {
    text-decoration: underline;
}

/* Tool Icon Variants */
.tool-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.tool-icon-sm {
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
    border-radius: 8px;
}

.tool-icon--admin {
    background: rgba(239, 68, 68, 0.125);
    color: #ef4444;
}

.tool-icon--signature {
    background: rgba(59, 130, 246, 0.125);
    color: #3b82f6;
}

.tool-icon--consistency {
    background: rgba(139, 92, 246, 0.125);
    color: #8b5cf6;
}

.tool-icon--calendar {
    background: rgba(245, 158, 11, 0.125);
    color: #f59e0b;
}

.tool-icon--gmail {
    background: rgba(234, 67, 53, 0.125);
    color: #ea4335;
}

/* Calendar Widget Events */
.event-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.event-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px dashed var(--border-main);
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
    color: inherit;
}

.event-item:hover {
    background: var(--bg-card-hover);
    border-radius: 8px;
    padding: 0.5rem;
    margin: -0.5rem;
    margin-bottom: 0.25rem;
}

.event-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.event-time {
    font-weight: 600;
    color: var(--primary);
    font-size: 0.85rem;
    background: var(--primary-light);
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.event-title {
    color: var(--text-main);
    font-size: 0.95rem;
    line-height: 1.4;
}

.loading-state {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-main);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Gmail Widget Items */
.email-item {
    display: block;
    padding: 0.75rem;
    padding-left: 0.5rem;
    margin: 0 -0.5rem;
    text-decoration: none;
    border-bottom: 1px solid var(--border-light);
    border-left: 3px solid transparent;
    transition: background 0.2s;
}

.email-item:hover {
    background: var(--bg-card-hover);
}

.email-item.unread {
    background: rgba(234, 67, 53, 0.05);
    /* Red tint 5% */
    border-left-color: #ea4335;
}

.email-item:last-child {
    border-bottom: none;
}

.email-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.email-sender {
    color: var(--text-main);
    font-size: 0.9rem;
    font-weight: 600;
}

.email-item.unread .email-sender {
    font-weight: 700;
}

.email-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.email-subject {
    font-size: 0.85rem;
    color: var(--text-main);
    font-weight: 500;
    margin-bottom: 2px;
}

.email-item.unread .email-subject {
    font-weight: 600;
}

.email-snippet {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.widget-empty-state {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-style: italic;
    text-align: center;
    padding: 1rem;
}

.widget-error-state {
    color: var(--error);
    font-size: 0.9rem;
    text-align: center;
    padding: 1rem;
}

/* =============================================
   NEW BADGE SYSTEM (Standardized)
   ============================================= */
.badge-role {
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
}

.badge-default {
    background: var(--bg-body);
    color: var(--text-muted);
    border: 1px solid var(--border-light);
}

.badge-red {
    background: var(--error-light);
    color: var(--error-dark);
    border: 1px solid var(--error-light);
}

.badge-green {
    background: var(--success-light);
    color: var(--success-dark);
    border: 1px solid var(--success-light);
}

.badge-blue {
    background: var(--info-light);
    color: var(--info-dark);
    border: 1px solid var(--info-light);
}

.badge-orange {
    background: var(--warning-light);
    color: var(--warning-dark);
    border: 1px solid var(--warning-light);
}

.badge-cyan {
    background: #e0f2fe;
    color: #0284c7;
    border: 1px solid #e0f2fe;
}

/* Outline Variants */
.badge-outline {
    background: transparent !important;
    border-style: solid;
    border-width: 1px;
}

.badge-outline.badge-green {
    color: var(--success);
    border-color: var(--success);
}

.badge-outline.badge-blue {
    color: var(--info);
    border-color: var(--info);
}

.badge-outline.badge-orange {
    color: var(--warning);
    border-color: var(--warning);
}

.badge-outline.badge-red {
    color: var(--error);
    border-color: var(--error);
}

.badge-outline.badge-cyan {
    color: #0891b2;
    border-color: #0891b2;
}

.badge-icon {
    width: 14px;
    height: 14px;
    margin-right: 4px;
    vertical-align: text-bottom;
}

/* =============================================
   PAGE HEADERS (Hero)
   ============================================= */
.page-header-hero {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

.page-header-icon {
    padding: 1rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.page-header-content {
    flex: 1;
}

.page-header-title {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-main);
    line-height: 1.2;
}

.page-header-subtitle {
    margin: 0.25rem 0 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.page-header-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* =============================================
   BREADCRUMBS
   ============================================= */
.breadcrumb-nav {
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
}

.breadcrumb-list {
    display: flex;
    align-items: center;
    list-style: none;
    padding: 0;
    margin: 0;
    gap: 0.5rem;
    color: var(--text-muted);
}

.breadcrumb-item {
    display: inline-flex;
    align-items: center;
}

.breadcrumb-item:not(:last-child)::after {
    content: '/';
    margin-left: 0.5rem;
    opacity: 0.5;
}

.breadcrumb-item a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumb-item a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.breadcrumb-item span {
    color: var(--text-main);
    font-weight: 500;
}

@media (max-width: 640px) {
    .page-header-hero {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .page-header-actions {
        width: 100%;
        justify-content: flex-start;
        margin-top: 0.5rem;
    }
}