/* ============================================
   PEPPOL Admin - Style CSS
   Sous-projet 1: Legal Entity & PEPPOL Activation
   ============================================ */

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Colors */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary: #64748b;
    --secondary-hover: #475569;
    --success: #10b981;
    --success-light: #d1fae5;
    --error: #ef4444;
    --error-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    
    /* Neutrals */
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    
    /* Layout */
    --sidebar-width: 400px;
    --header-height: 80px;
    --border-radius: 8px;
    --border-radius-sm: 6px;
    --border-radius-lg: 12px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
    
    /* Transitions */
    --transition: all 0.2s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Container */
.container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================
   Header
   ============================================ */
.header {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 1.5rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-content h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 0.25rem;
}

.subtitle {
    font-size: 0.95rem;
    color: var(--gray-500);
    font-weight: 400;
}

/* ============================================
   Main Content - Split View
   ============================================ */
.main-content {
    display: flex;
    flex: 1;
    height: calc(100vh - var(--header-height));
    overflow: hidden;
}

/* Left Panel */
.left-panel {
    width: var(--sidebar-width);
    background: white;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--gray-50);
}

.panel-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-900);
}

/* Search Bar */
.search-bar {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 0.95rem;
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Entity List */
.entity-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.entity-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

.entity-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateX(4px);
}

.entity-card.active {
    border-color: var(--primary);
    background: var(--primary-light);
}

.entity-card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 0.5rem;
}

.entity-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--gray-900);
    margin-bottom: 0.25rem;
}

.entity-vat {
    font-size: 0.875rem;
    color: var(--gray-600);
    font-family: 'Courier New', monospace;
}

.entity-address {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-top: 0.5rem;
}

/* Right Panel */
.right-panel {
    flex: 1;
    background: var(--gray-50);
    overflow-y: auto;
    position: relative;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem;
    text-align: center;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.5rem;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--gray-500);
    font-size: 1rem;
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 1rem;
}

.spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
    margin-right: 0.5rem;
}

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

/* ============================================
   Form Container
   ============================================ */
.form-container,
.details-container {
    background: white;
    height: 100%;
    overflow-y: auto;
}

.form-header,
.details-header {
    position: sticky;
    top: 0;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    box-shadow: var(--shadow-sm);
}

.form-header h2,
.details-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--gray-900);
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0.5rem;
    line-height: 1;
    transition: var(--transition);
}

.btn-close:hover {
    color: var(--gray-600);
}

/* Form */
#legalEntityForm {
    padding: 2rem;
    max-width: 800px;
}

.form-section {
    margin-bottom: 2rem;
}

.form-section h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--gray-200);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.form-group label.required::after {
    content: " *";
    color: var(--error);
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 0.95rem;
    transition: var(--transition);
    font-family: inherit;
}

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

.form-input:read-only {
    background: var(--gray-100);
    cursor: not-allowed;
}

.form-hint {
    display: block;
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-top: 0.375rem;
}

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

.alert-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.alert-content strong {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.alert-content p {
    font-size: 0.95rem;
    margin: 0;
}

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

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

/* Form Actions */
.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding-top: 1.5rem;
    border-top: 1px solid var(--gray-200);
    margin-top: 2rem;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: inherit;
}

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

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: white;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.btn .icon {
    font-size: 1.125rem;
    line-height: 1;
}

/* ============================================
   Details View
   ============================================ */
.details-content {
    padding: 2rem;
    max-width: 900px;
}

.details-section {
    margin-bottom: 2.5rem;
}

.details-section h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--gray-200);
}

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

.details-item {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.details-item.full-width {
    grid-column: 1 / -1;
}

.details-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.details-value {
    font-size: 1rem;
    color: var(--gray-900);
    font-weight: 400;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: capitalize;
}

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

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

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

/* PEPPOL Identifier Card */
.peppol-id-card {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.peppol-id-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.peppol-id-scheme {
    font-weight: 600;
    color: var(--gray-900);
    font-family: 'Courier New', monospace;
}

.peppol-id-identifier {
    font-size: 1.125rem;
    color: var(--gray-700);
    font-family: 'Courier New', monospace;
    margin-bottom: 0.5rem;
}

.peppol-id-meta {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.no-peppol-ids {
    text-align: center;
    padding: 2rem;
    color: var(--gray-400);
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 350px;
    }
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
        height: auto;
    }
    
    .left-panel {
        width: 100%;
        max-height: 50vh;
    }
    
    .right-panel {
        width: 100%;
    }
    
    .details-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Scrollbar Styling
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.entity-card {
    animation: fadeIn 0.3s ease;
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .header,
    .left-panel,
    .form-actions,
    .btn-close {
        display: none;
    }
    
    .right-panel {
        width: 100%;
    }
}
