/**
 * Styles CSS - Suivi Troupeau Agnelles
 * Lycée Agricole Campus Corsic'Agri
 * Application responsive smartphone
 */

/* ==========================================
   RESET & BASE
   ========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f0f2f5;
    color: #2c3e50;
    line-height: 1.5;
    min-height: 100vh;
}

/* ==========================================
   VARIABLES COULEURS
   ========================================== */
:root {
    --color-intervenant: #27ae60;
    --color-intervenant-dark: #1e8449;
    --color-superviseur: #8e44ad;
    --color-superviseur-dark: #6c3483;
    --color-archives: #e67e22;
    --color-archives-dark: #d35400;
    --color-danger: #e74c3c;
    --color-success: #27ae60;
    --color-warning: #f39c12;
    --color-info: #3498db;
    --color-gray-light: #f8f9fa;
    --color-gray: #95a5a6;
    --color-gray-dark: #7f8c8d;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --radius: 12px;
}

/* ==========================================
   PAGE DE CONNEXION
   ========================================== */
.login-page {
    background: linear-gradient(135deg, var(--color-superviseur), #9b59b6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    background: white;
    border-radius: 20px;
    padding: 40px 30px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo {
    font-size: 4rem;
    margin-bottom: 15px;
}

.login-header h1 {
    font-size: 1.5rem;
    color: #2c3e50;
    margin-bottom: 5px;
}

.login-subtitle {
    color: var(--color-gray-dark);
    font-size: 0.9rem;
}

/* Sélection profil */
.profile-selection {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
}

.profile-option {
    flex: 1;
    cursor: pointer;
}

.profile-option input {
    display: none;
}

.profile-card {
    padding: 20px 15px;
    border-radius: var(--radius);
    text-align: center;
    transition: all 0.3s ease;
    border: 2px solid #e0e0e0;
}

.profile-card .profile-icon {
    display: block;
    font-size: 2rem;
    margin-bottom: 8px;
}

.profile-card .profile-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #555;
}

.profile-option.selected .profile-card.intervenant,
.profile-option input:checked + .profile-card.intervenant {
    border-color: var(--color-intervenant);
    background: linear-gradient(135deg, var(--color-intervenant), #2ecc71);
    color: white;
}

.profile-option.selected .profile-card.intervenant .profile-label,
.profile-option input:checked + .profile-card.intervenant .profile-label {
    color: white;
}

.profile-option.selected .profile-card.superviseur,
.profile-option input:checked + .profile-card.superviseur {
    border-color: var(--color-superviseur);
    background: linear-gradient(135deg, var(--color-superviseur), #9b59b6);
    color: white;
}

.profile-option.selected .profile-card.superviseur .profile-label,
.profile-option input:checked + .profile-card.superviseur .profile-label {
    color: white;
}

/* Champ mot de passe */
.password-group {
    margin-bottom: 20px;
}

.password-input-wrapper {
    position: relative;
}

.password-input-wrapper input {
    width: 100%;
    padding: 14px;
    padding-right: 50px;
    border: 2px solid #e0e0e0;
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.3s;
}

.password-input-wrapper input:focus {
    outline: none;
    border-color: var(--color-superviseur);
}

.toggle-password {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 5px;
}

/* ==========================================
   HEADER APPLICATION
   ========================================== */
.app-header {
    padding: 20px;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-header.intervenant {
    background: linear-gradient(135deg, var(--color-intervenant), #2ecc71);
}

.app-header.superviseur {
    background: linear-gradient(135deg, var(--color-superviseur), #9b59b6);
}

.app-header.archives {
    background: linear-gradient(135deg, var(--color-archives), #f39c12);
}

.header-content h1 {
    font-size: 1.2rem;
    margin-bottom: 3px;
}

.header-content p {
    font-size: 0.8rem;
    opacity: 0.9;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.btn-logout, .btn-back, .btn-icon {
    background: rgba(255,255,255,0.2);
    color: white;
    text-decoration: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: background 0.3s;
}

.btn-logout:hover, .btn-back:hover, .btn-icon:hover {
    background: rgba(255,255,255,0.3);
}

/* ==========================================
   CONTENU PRINCIPAL
   ========================================== */
.app-content {
    padding: 20px;
    max-width: 600px;
    margin: 0 auto;
}

.back-link {
    display: inline-block;
    color: var(--color-gray-dark);
    text-decoration: none;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.back-link:hover {
    color: #2c3e50;
}

/* ==========================================
   FORMULAIRES
   ========================================== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: #555;
    margin-bottom: 8px;
}

.form-group label .required {
    color: var(--color-danger);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 14px;
    border: 2px solid #e0e0e0;
    border-radius: var(--radius);
    font-size: 1rem;
    background: #fafafa;
    transition: border-color 0.3s, background 0.3s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--color-intervenant);
    background: white;
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--color-gray);
    margin-top: 5px;
}

/* Horodatage */
.timestamp-display {
    background: #ecf0f1;
    padding: 12px 15px;
    border-radius: var(--radius);
    text-align: center;
    margin-bottom: 20px;
    border-left: 4px solid var(--color-intervenant);
    font-size: 0.95rem;
    color: var(--color-gray-dark);
}

.timestamp-display strong {
    color: #2c3e50;
}

/* Zone photo */
.photo-zone {
    border: 2px dashed #bdc3c7;
    border-radius: var(--radius);
    overflow: hidden;
    background: #fafafa;
}

.photo-placeholder {
    padding: 30px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.photo-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.photo-placeholder p {
    color: var(--color-gray);
    margin-bottom: 15px;
}

.photo-buttons {
    display: flex;
    gap: 10px;
}

.btn-camera, .btn-gallery {
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    border: none;
}

.btn-camera {
    background: var(--color-info);
    color: white;
}

.btn-gallery {
    background: var(--color-superviseur);
    color: white;
}

.photo-preview {
    position: relative;
}

.photo-preview img {
    width: 100%;
    display: block;
}

.btn-remove-photo {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--color-danger);
    color: white;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==========================================
   BOUTONS
   ========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: opacity 0.3s, transform 0.2s;
}

.btn:hover {
    opacity: 0.9;
}

.btn:active {
    transform: scale(0.98);
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-superviseur), #9b59b6);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, var(--color-intervenant), #2ecc71);
    color: white;
}

.btn-orange {
    background: linear-gradient(135deg, var(--color-archives), #f39c12);
    color: white;
}

.btn-secondary {
    background: var(--color-gray);
    color: white;
}

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

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

/* ==========================================
   ALERTES
   ========================================== */
.alert {
    padding: 15px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.alert-success {
    background: #d4edda;
    border: 1px solid #28a745;
    color: #155724;
}

.alert-error {
    background: #f8d7da;
    border: 1px solid #dc3545;
    color: #721c24;
}

.alert-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--color-success);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.alert-content strong {
    display: block;
    margin-bottom: 5px;
}

/* ==========================================
   STATISTIQUES (Dashboard)
   ========================================== */
.stats-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.stat-box {
    flex: 1;
    background: white;
    padding: 15px 10px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-number {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--color-superviseur);
}

.stat-box.alert .stat-number {
    color: var(--color-danger);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--color-gray-dark);
    margin-top: 3px;
}

/* ==========================================
   FILTRES
   ========================================== */
.filter-section {
    margin-bottom: 20px;
}

.btn-filter {
    background: var(--color-warning);
    color: white;
    width: 100%;
    margin-bottom: 10px;
}

.filter-panel {
    background: white;
    padding: 15px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.filter-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.filter-group {
    flex: 1;
}

.filter-group label {
    font-size: 0.8rem;
    color: var(--color-gray-dark);
    margin-bottom: 5px;
    display: block;
}

.filter-group select,
.filter-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.9rem;
}

.filter-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.filter-actions .btn {
    flex: 1;
    padding: 10px;
}

/* ==========================================
   LISTE OBSERVATIONS
   ========================================== */
.section-header {
    margin-bottom: 15px;
}

.section-header h2 {
    font-size: 1rem;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 10px;
}

.badge {
    background: var(--color-gray);
    color: white;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: normal;
}

.badge-alert {
    background: var(--color-danger);
}

.observations-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.observation-card {
    background: white;
    border-radius: var(--radius);
    padding: 12px;
    display: flex;
    gap: 12px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s;
    position: relative;
}

.observation-card:hover {
    transform: translateX(5px);
}

.observation-card.recent {
    border-left: 4px solid var(--color-danger);
    background: #fff5f5;
}

.observation-card.non-vue {
    border-left: 4px solid var(--color-danger);
}

.obs-photo {
    width: 50px;
    height: 50px;
    background: #ecf0f1;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.obs-photo.has-photo {
    background: #d5f4e6;
}

.obs-content {
    flex: 1;
    min-width: 0;
}

.obs-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.obs-intervenant {
    font-weight: 600;
    font-size: 0.9rem;
    color: #2c3e50;
}

.obs-time {
    font-size: 0.75rem;
    color: var(--color-gray);
}

.obs-text {
    font-size: 0.85rem;
    color: var(--color-gray-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.obs-badge-new {
    position: absolute;
    top: 10px;
    right: 10px;
    color: var(--color-danger);
    font-size: 0.8rem;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-gray);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 15px;
}

.empty-hint {
    font-size: 0.85rem;
    margin-top: 10px;
}

/* ==========================================
   TOOLBAR
   ========================================== */
.toolbar {
    display: flex;
    gap: 10px;
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    max-width: 560px;
    margin: 0 auto;
}

.tool-btn {
    flex: 1;
    padding: 12px 10px;
    border-radius: var(--radius);
    border: none;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: opacity 0.3s;
}

.tool-btn:hover {
    opacity: 0.9;
}

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

.tool-btn.notif {
    background: var(--color-info);
    color: white;
}

.tool-btn.notif:not(.active) {
    background: var(--color-gray);
}

.tool-btn.archives {
    background: var(--color-archives);
    color: white;
}

.tool-icon {
    font-size: 1.3rem;
}

.tool-label {
    font-size: 0.75rem;
    font-weight: 500;
}

/* Espace pour la toolbar fixe */
.superviseur-page .app-content {
    padding-bottom: 100px;
}

/* ==========================================
   MODAL
   ========================================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 20px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 15px 20px;
    background: var(--color-superviseur);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1rem;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.detail-timestamp {
    background: #ecf0f1;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 15px;
    text-align: center;
}

.detail-intervenant,
.detail-observations {
    margin-bottom: 15px;
}

.detail-observations p {
    margin-top: 5px;
    white-space: pre-wrap;
}

.detail-photo {
    margin-top: 15px;
}

.detail-photo img {
    width: 100%;
    border-radius: 8px;
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--color-gray);
}

/* ==========================================
   ARCHIVES
   ========================================== */
.archive-search {
    background: white;
    padding: 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.archive-search h3 {
    font-size: 1rem;
    margin-bottom: 15px;
    color: #2c3e50;
}

.search-form .date-range {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.date-field {
    flex: 1;
}

.date-field label {
    font-size: 0.8rem;
    color: var(--color-gray-dark);
    margin-bottom: 5px;
    display: block;
}

.date-field input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.archives-by-month h3,
.archives-detail h3 {
    font-size: 1rem;
    color: #2c3e50;
    margin-bottom: 15px;
}

.archive-card {
    display: block;
    background: white;
    border-radius: var(--radius);
    padding: 15px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    border-left: 4px solid var(--color-archives);
    transition: transform 0.2s;
}

.archive-card:hover {
    transform: translateX(5px);
}

.archive-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.archive-period {
    font-weight: 600;
    color: #2c3e50;
}

.archive-badge {
    background: #fef3e7;
    color: var(--color-archives);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
}

.archive-stats {
    display: flex;
    gap: 15px;
    font-size: 0.85rem;
    color: var(--color-gray-dark);
}

.archives-detail-header {
    background: #fef3e7;
    padding: 15px;
    border-radius: var(--radius);
    margin-bottom: 15px;
    border-left: 4px solid var(--color-archives);
}

.archives-detail-header h3 {
    color: var(--color-archives-dark);
    margin-bottom: 5px;
}

.archives-detail-header p {
    font-size: 0.85rem;
    color: var(--color-gray-dark);
}

.archive-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.archive-toolbar .btn {
    flex: 1;
    padding: 10px;
}

.archive-observation {
    background: #fafafa;
    border-radius: var(--radius);
    padding: 15px;
    margin-bottom: 10px;
}

.archive-observation .obs-header {
    margin-bottom: 8px;
}

.archive-observation .obs-date {
    font-size: 0.8rem;
    color: var(--color-archives);
    font-weight: 500;
}

.archive-observation .obs-intervenant {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
}

.archive-observation .obs-text {
    font-size: 0.9rem;
    color: #555;
    line-height: 1.5;
    white-space: normal;
}

.obs-photo-indicator {
    margin-top: 10px;
    font-size: 0.8rem;
    color: var(--color-info);
    display: flex;
    align-items: center;
    gap: 10px;
}

.view-photo {
    color: var(--color-info);
    text-decoration: underline;
}

.info-box {
    background: #e8f4fd;
    border: 1px solid var(--color-info);
    border-radius: var(--radius);
    padding: 15px;
    margin-top: 20px;
}

.info-box h4 {
    color: var(--color-info);
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.info-box ul {
    margin-left: 20px;
    font-size: 0.85rem;
    color: #555;
}

.info-box li {
    margin-bottom: 5px;
}

/* ==========================================
   PARAMETRES
   ========================================== */
.settings-section {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.settings-section h3 {
    font-size: 1rem;
    color: #2c3e50;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.settings-form .form-group {
    margin-bottom: 15px;
}

.settings-form .btn {
    margin-top: 10px;
}

.maintenance-actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.inline-form {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.inline-form .btn {
    width: 100%;
    margin-bottom: 8px;
}

.info-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.info-label {
    color: var(--color-gray-dark);
}

.info-value {
    font-weight: 500;
    color: #2c3e50;
}

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 400px) {
    .login-container {
        padding: 30px 20px;
    }
    
    .profile-selection {
        flex-direction: column;
    }
    
    .stats-bar {
        flex-wrap: wrap;
    }
    
    .stat-box {
        min-width: calc(50% - 5px);
    }
    
    .filter-row {
        flex-direction: column;
    }
    
    .toolbar {
        left: 10px;
        right: 10px;
    }
}

@media (min-width: 768px) {
    .login-page {
        padding: 40px;
    }
    
    .app-content {
        padding: 30px;
    }
}
