* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Couleurs principales - identiques au site web */
    --primary-color: #f97316;
    --primary-dark: #ea580c;
    --primary-light: #fb923c;
    --secondary-color: #6366f1;
    --secondary-dark: #4f46e5;

    /* Couleurs d'etat */
    --error-color: #dc2626;
    --success-color: #16a34a;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;

    /* Couleurs de texte */
    --text-color: #1f2937;
    --text-light: #6b7280;

    /* Couleurs de fond */
    --bg-color: #f3f4f6;
    --white: #ffffff;
    --border-color: #e5e7eb;

    /* Ombres */
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    line-height: 1.5;
}

#app {
    min-height: 100vh;
}

.page {
    min-height: 100vh;
}

/* ============================================
   PAGE DE CONNEXION - MOBILE FIRST
   ============================================ */

#login-page {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile */
    background: linear-gradient(160deg, #ff8c42 0%, #f97316 30%, #ea580c 70%, #c2410c 100%);
    position: relative;
    overflow: hidden;
}

/* Effet de fond decoratif */
#login-page::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%);
    pointer-events: none;
}

#login-page::after {
    content: '';
    position: absolute;
    bottom: -40%;
    left: -20%;
    width: 80%;
    height: 80%;
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 50%);
    pointer-events: none;
}

.login-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    padding: 24px 24px;
    position: relative;
    z-index: 1;
}

/* Header avec logo */
.login-header {
    text-align: center;
    padding-top: 40px;
    padding-bottom: 32px;
}

.login-logo-container {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: var(--white);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.login-logo {
    max-width: 56px;
    height: auto;
}

.login-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--white);
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.login-subtitle {
    font-size: 16px;
    color: rgba(255,255,255,0.9);
    font-weight: 400;
}

/* Formulaire */
.login-form-container {
    background: var(--white);
    border-radius: 24px;
    padding: 32px 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.form-group {
    margin-bottom: 16px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 16px;
    color: var(--text-light);
    pointer-events: none;
    transition: color 0.2s;
}

.input-wrapper input {
    width: 100%;
    padding: 16px 16px 16px 48px;
    border: 2px solid var(--border-color);
    border-radius: 14px;
    font-size: 16px;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    background: var(--bg-color);
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--white);
    box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.1);
}

.input-wrapper input:focus + .input-icon,
.input-wrapper:focus-within .input-icon {
    color: var(--primary-color);
}

.input-wrapper input::placeholder {
    color: #9ca3af;
}

/* Toggle password */
.toggle-password {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.toggle-password:hover,
.toggle-password:focus {
    color: var(--primary-color);
    outline: none;
}

/* Error message */
.error-message {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    color: var(--error-color);
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 14px;
    margin-bottom: 16px;
    border: 1px solid #fecaca;
    display: flex;
    align-items: center;
    gap: 10px;
}

.error-message::before {
    content: '!';
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: var(--error-color);
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

/* Boutons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 16px 24px;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
}

.btn-login {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white);
    width: 100%;
    height: 56px;
    font-size: 17px;
    box-shadow: 0 4px 16px rgba(249, 115, 22, 0.3);
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(249, 115, 22, 0.4);
}

.btn-login:active {
    transform: translateY(0);
}

.btn-login:disabled {
    opacity: 0.8;
    cursor: not-allowed;
    transform: none;
}

/* Loader spinner */
.loader-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 10px;
}

/* Forgot password link */
.forgot-password-link {
    display: block;
    text-align: center;
    margin-top: 20px;
    color: var(--text-light);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

.forgot-password-link:hover {
    color: var(--primary-color);
}

/* Footer */
.login-footer {
    margin-top: auto;
    padding: 32px 0 24px;
    text-align: center;
}

.login-footer p {
    color: rgba(255,255,255,0.8);
    font-size: 14px;
    margin-bottom: 8px;
}

.signup-link {
    color: var(--white);
    font-weight: 600;
    text-decoration: none;
    font-size: 15px;
    padding: 8px 16px;
    border: 2px solid rgba(255,255,255,0.4);
    border-radius: 10px;
    display: inline-block;
    transition: all 0.2s;
}

.signup-link:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.6);
}

/* Compatibilite ancien style (pour autres pages) */
.btn-primary {
    background-color: var(--primary-color);
    color: var(--white);
    width: 100%;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Safe area iOS pour login */
@supports (padding-top: env(safe-area-inset-top)) {
    .login-header {
        padding-top: calc(40px + env(safe-area-inset-top));
    }

    .login-footer {
        padding-bottom: calc(24px + env(safe-area-inset-bottom));
    }
}

/* Page d'accueil */
#home-page {
    display: flex;
    flex-direction: column;
}

.header {
    background: var(--primary-color);
    color: var(--white);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-logo {
    height: 32px;
    width: auto;
    display: none;
}

/* Afficher le logo sur desktop */
@media (min-width: 768px) {
    .header-logo {
        display: block;
    }
}

.header h1 {
    font-size: 20px;
    font-weight: 600;
}

.btn-logout {
    background: rgba(255, 255, 255, 0.15);
    color: var(--white);
    padding: 8px 16px;
    font-size: 14px;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.25);
}

.main-content {
    flex: 1;
    padding: 20px;
}

.welcome-card {
    background: var(--white);
    border-radius: 16px;
    padding: 30px;
    text-align: center;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.avatar {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 600;
    margin: 0 auto 20px;
}

.welcome-card h2 {
    font-size: 22px;
    margin-bottom: 8px;
}

.welcome-card p {
    color: var(--text-light);
    font-size: 14px;
}

.company-name {
    color: var(--primary-color) !important;
    font-weight: 500;
    margin-top: 5px;
}

.info-card {
    background: var(--white);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.info-card p {
    color: var(--text-light);
    text-align: center;
    font-size: 14px;
}

/* Bouton Ajouter Photo */
.btn-add-photo {
    gap: 10px;
    margin-bottom: 20px;
}

.btn-add-photo svg {
    flex-shrink: 0;
}

/* Section Projets */
.projects-section {
    margin-bottom: 80px;
}

.projects-section h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-color);
}

.projects-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.project-card {
    background: var(--white);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.project-card:active {
    transform: scale(0.98);
}

.project-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.project-icon svg {
    color: var(--white);
}

.project-info {
    flex: 1;
    min-width: 0;
}

.project-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-count {
    font-size: 13px;
    color: var(--text-light);
    margin-top: 4px;
}

.project-arrow {
    color: var(--text-light);
    flex-shrink: 0;
}

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

.empty-text {
    text-align: center;
    color: var(--text-light);
    padding: 30px 20px;
    background: var(--white);
    border-radius: 12px;
}

/* Bouton flottant */
.fab-camera {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white);
    border: none;
    box-shadow: 0 4px 16px rgba(249, 115, 22, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 50;
}

.fab-camera:active {
    transform: scale(0.95);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 200;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--white);
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

.modal-small {
    max-height: 50vh;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-light);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(80vh - 70px);
}

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

.modal-project-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--bg-color);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
}

.modal-project-item:active {
    background: var(--border-color);
}

.modal-project-item .project-name {
    flex: 1;
}

.modal-project-item .project-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
}

/* Source Photo Modal */
.source-project-name {
    text-align: center;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.source-buttons {
    display: flex;
    gap: 16px;
}

.source-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 24px 16px;
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.source-btn:active {
    background: var(--border-color);
    border-color: var(--primary-color);
}

.source-btn svg {
    color: var(--primary-color);
}

.source-btn span {
    font-weight: 600;
    color: var(--text-color);
}

/* Upload Progress */
.upload-progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
}

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

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

#upload-status {
    color: var(--text-color);
    font-weight: 500;
}

/* Success message */
.success-message {
    background-color: #f0fdf4;
    color: var(--success-color);
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 20px;
    border: 1px solid #bbf7d0;
    text-align: center;
}

/* ============================================
   PAGE DETAIL PROJET
   ============================================ */

/* Header avec bouton retour */
.header-with-back {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-with-back h1 {
    flex: 1;
    text-align: center;
    font-size: 18px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 40px;
}

.btn-back {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: var(--white);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.btn-back:active {
    background: rgba(255, 255, 255, 0.25);
}

.btn-header-action {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: var(--white);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.btn-header-action:active {
    background: rgba(255, 255, 255, 0.25);
}

.header-spacer {
    width: 40px;
    flex-shrink: 0;
}

/* Liste des images */
.images-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.image-list-item {
    background: var(--white);
    border-radius: 12px;
    padding: 12px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.image-list-item:active {
    transform: scale(0.98);
}

.image-thumbnail {
    width: 70px;
    height: 70px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-color);
}

.image-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-list-info {
    flex: 1;
    min-width: 0;
}

.image-list-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-list-date {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 4px;
}

.image-list-desc {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.image-list-arrow {
    color: var(--text-light);
    flex-shrink: 0;
}

/* ============================================
   PAGE DETAIL IMAGE
   ============================================ */

#project-detail-page {
    flex-direction: column;
}

/* Header sombre pour image */
.header-dark {
    background: #1a1a1a;
}

#image-detail-page {
    background: #1a1a1a;
    flex-direction: column;
}

.image-detail-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.image-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #000;
    min-height: 200px;
}

.image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.image-info {
    background: var(--white);
    padding: 20px;
    border-radius: 20px 20px 0 0;
    max-height: 40vh;
    overflow-y: auto;
}

.image-description {
    font-size: 15px;
    color: var(--text-color);
    line-height: 1.6;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.image-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.image-meta-item {
    font-size: 13px;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 8px;
}

.image-meta-item:first-child {
    font-weight: 500;
    color: var(--text-color);
}

/* Safe area pour iOS */
@supports (padding-top: env(safe-area-inset-top)) {
    .header {
        padding-top: calc(16px + env(safe-area-inset-top));
    }

    #login-page {
        padding-top: calc(20px + env(safe-area-inset-top));
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }

    .fab-camera {
        bottom: calc(24px + env(safe-area-inset-bottom));
    }

    .modal-content {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .image-info {
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }
}
