/* ================================================================
   Saint-Rivoal CMS — Stylesheet
   Themed to match the municipal website (green/teal/blue palette).
   ================================================================ */

/* ---- Design Tokens (matching main site) ---- */
:root {
    --color-green-light: #cad87ac8;
    --color-green: #c6e1ae;
    --color-teal: #a3d8cc;
    --color-blue-light: #a4cfdd;
    --color-blue: #b4c9f1;
    --color-blue-dark: #31589c;

    --color-primary: #31589c;              /* Site's blue-dark — links/actions */
    --color-primary-dark: #264573;
    --color-primary-light: #4a7cc0;
    --color-secondary: #a3d8cc;            /* Teal — secondary actions */

    --color-bg: #f5f5f5;                   /* Site's grey-light */
    --color-bg-panel: #ffffff;
    --color-bg-hover: #e8f4ec;
    --color-bg-input: #fafafa;

    --color-text: #2c2c2c;
    --color-text-muted: #5a5a5a;
    --color-text-light: #888888;

    --color-border: #d0d0d0;
    --color-border-light: #e0e0e0;

    --color-error: #c45b4a;
    --color-error-bg: #fdf0ee;
    --color-success: #4a7c59;
    --color-success-bg: #eff6f0;
    --color-info: #31589c;
    --color-info-bg: #edf3f8;
    --color-warning: #8c7a3e;
    --color-warning-bg: #fbf6e9;

    --font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --transition: 0.2s ease;
}

/* ---- Reset ---- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

body {
    font-family: var(--font-family);
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}

/* ---- Header ---- */
.cms-header {
    background: #fff;
    border-bottom: 1px solid var(--color-border-light);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 100%;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    color: var(--color-text);
}

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

.brand-text strong {
    color: var(--color-text);
}

.header-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-name {
    font-weight: 500;
    color: var(--color-text-muted);
}

.logout-form {
    display: inline;
}

.btn-logout {
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-family);
}

.btn-logout:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

/* ---- Main layout ---- */
.cms-main {
    height: calc(100vh - 52px);
}

/* ---- Login ---- */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 52px);
    padding: 2rem;
    background: #fff;
}

.login-card {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 1rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text);
    margin-bottom: 0.25rem;
}

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

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.warm-up-notice {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--color-bg-hover);
    border: 1px dashed var(--color-secondary);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
    color: var(--color-primary);
    animation: pulse-notice 2s infinite ease-in-out;
}

@keyframes pulse-notice {
    0% { opacity: 0.7; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

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

/* ---- Forms ---- */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--color-text);
    margin-bottom: 0.35rem;
    letter-spacing: 0.01em;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="date"],
.form-group input[type="number"],
.form-select,
.form-group textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-family: var(--font-family);
    font-size: 0.9375rem;
    color: var(--color-text);
    background: var(--color-bg-input);
    transition: var(--transition);
    outline: none;
}

.form-group input:focus,
.form-select:focus,
.form-group textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(49, 88, 156, 0.12);
}

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

.form-group input[type="file"] {
    font-family: var(--font-family);
    font-size: 0.875rem;
    padding: 0.5rem;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg-input);
    cursor: pointer;
    width: 100%;
}

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

.help-text {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 0.35rem;
    font-style: italic;
}

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

.inline-fields {
    display: flex;
    gap: 0.75rem;
}

.inline-field {
    flex: 1;
}

/* ---- Checkbox groups ---- */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.35rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    padding: 0.3rem 0;
}

.checkbox-label input[type="checkbox"] {
    accent-color: var(--color-primary);
    width: 16px;
    height: 16px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.checkbox-row-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-muted);
    min-width: 130px;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius);
    font-family: var(--font-family);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary:disabled {
    background: var(--color-border);
    color: var(--color-text-light);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: var(--color-teal);
    color: var(--color-text);
}

.btn-secondary:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

.btn-secondary:disabled {
    background: var(--color-border);
    color: var(--color-text-light);
    cursor: not-allowed;
    transform: none;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
}

.btn-outline:hover {
    background: var(--color-bg-hover);
    border-color: var(--color-primary-light);
    color: var(--color-primary);
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
    border: none;
}

.btn-ghost:hover {
    color: var(--color-error);
}

.btn-small {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.btn-full {
    width: 100%;
}

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

.alert-icon {
    flex-shrink: 0;
    margin-top: 0.1rem;
    font-weight: 700;
}

.alert-error {
    background: var(--color-error-bg);
    color: var(--color-error);
    border: 1px solid rgba(196, 91, 74, 0.2);
}

.alert-info {
    background: var(--color-info-bg);
    color: var(--color-info);
    border: 1px solid rgba(49, 88, 156, 0.2);
}

.alert-success {
    background: var(--color-success-bg);
    color: var(--color-success);
    border: 1px solid rgba(74, 124, 89, 0.2);
}

.alert-warning {
    background: var(--color-warning-bg);
    color: var(--color-warning);
    border: 1px solid rgba(140, 122, 62, 0.2);
}

.lock-detail {
    font-size: 0.8rem;
    margin-top: 0.25rem;
    opacity: 0.8;
}

/* ---- Editor Layout ---- */
.editor-layout {
    display: flex;
    height: calc(100vh - 52px);
    overflow: hidden;
}

.editor-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.editor-form-panel {
    width: 45%;
    border-right: 1px solid var(--color-border-light);
    background: var(--color-bg-panel);
}

.editor-preview-panel {
    width: 55%;
    background: var(--color-bg);
}

.panel-header {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--color-border-light);
    background: #fff;
}

.panel-header h2 {
    font-size: 0.85rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
    text-align: center;
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
}

/* ---- Action Bar ---- */
.action-bar {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--color-border-light);
    background: var(--color-bg-panel);
    flex-wrap: wrap;
}

/* ---- Preview Panel ---- */
.preview-body {
    padding: 0;
    position: relative;
}

.preview-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem;
}

.placeholder-content {
    text-align: center;
    color: var(--color-text-muted);
}

.placeholder-content h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--color-text-muted);
}

.placeholder-content p {
    font-size: 0.9rem;
    max-width: 300px;
    margin: 0 auto;
}

.preview-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 1rem;
    color: var(--color-text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-border-light);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ---- Image Preview ---- */
.image-preview {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: var(--color-bg);
    border-radius: var(--radius);
    border: 1px solid var(--color-border-light);
}

.image-preview img {
    max-width: 200px;
    max-height: 150px;
    border-radius: 4px;
    display: block;
    margin-bottom: 0.5rem;
}

.format-info {
    font-size: 0.85rem;
    font-weight: 500;
}

.format-info.detected {
    color: var(--color-success);
}

.format-info.ambiguous {
    color: var(--color-warning);
}

.image-warnings {
    margin-top: 0.35rem;
}

.image-warnings p {
    font-size: 0.8rem;
    color: var(--color-warning);
    font-style: italic;
}

/* ---- PDF Preview ---- */
.pdf-preview {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--color-bg);
    border-radius: var(--radius);
    border: 1px solid var(--color-border-light);
    font-size: 0.9rem;
}

/* ---- Radio buttons ---- */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.35rem;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.3rem 0;
}

.radio-label input[type="radio"] {
    accent-color: var(--color-primary);
}

/* ---- Colour Palette ---- */
.colour-palette {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 0.5rem 0;
}

.colour-swatch {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.colour-swatch:hover {
    transform: scale(1.15);
    box-shadow: var(--shadow-md);
}

.colour-swatch.selected {
    border-color: var(--color-text);
    box-shadow: 0 0 0 2px var(--color-bg-panel), 0 0 0 4px var(--color-text);
}

/* ---- Card Position List ---- */
.position-list {
    margin-bottom: 0.5rem;
}

.position-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border-light);
}

.position-card:last-child {
    border-bottom: none;
}

.position-number {
    font-weight: 700;
    color: var(--color-text-light);
    min-width: 1.5rem;
}

/* ---- Auto-title display ---- */
.auto-title-display {
    padding: 0.5rem 0.75rem;
    background: var(--color-bg);
    border-radius: var(--radius);
    border: 1px solid var(--color-border-light);
    color: var(--color-text-muted);
    font-style: italic;
    font-size: 0.9rem;
}

/* ---- Language tabs for bilingual content ---- */
.lang-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--color-border-light);
    margin-bottom: 1rem;
}

.lang-tab {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    border: none;
    background: none;
    color: var(--color-text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
}

.lang-tab:hover {
    color: var(--color-primary);
}

.lang-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.lang-panel {
    display: none;
}

.lang-panel.active {
    display: block;
}

/* ---- Summary / Full content sections ---- */
.content-section {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--color-bg);
    border-radius: var(--radius);
    border: 1px solid var(--color-border-light);
}

.content-section label {
    font-weight: 600;
    color: var(--color-primary);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    display: block;
}

/* ---- Modal ---- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(3px);
}

.modal-content {
    position: relative;
    background: var(--color-bg-panel);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 480px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

.modal-content p {
    margin-bottom: 1.25rem;
    color: var(--color-text-muted);
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
}

/* ---- Toast Notifications ---- */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toast-in 0.3s ease;
    max-width: 400px;
}

.toast-success {
    background: var(--color-success);
    color: #fff;
}

.toast-error {
    background: var(--color-error);
    color: #fff;
}

.toast-info {
    background: var(--color-primary);
    color: #fff;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---- Utility ---- */
.hidden {
    display: none !important;
}

/* ---- New Badge Form ---- */
.new-badge-form {
    padding: 0.75rem;
    background: var(--color-bg);
    border-radius: var(--radius);
    border: 1px solid var(--color-border-light);
}

/* ---- EasyMDE overrides ---- */
.EasyMDEContainer {
    border-radius: var(--radius) !important;
}

.EasyMDEContainer .CodeMirror {
    font-family: var(--font-family) !important;
    font-size: 0.9375rem !important;
    border-radius: 0 0 var(--radius) var(--radius) !important;
    border-color: var(--color-border) !important;
    background: var(--color-bg-input) !important;
}

.editor-toolbar {
    border-color: var(--color-border) !important;
    border-radius: var(--radius) var(--radius) 0 0 !important;
    background: var(--color-bg) !important;
}

.editor-toolbar button:hover {
    background: var(--color-bg-hover) !important;
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .editor-layout {
        flex-direction: column;
    }

    .editor-form-panel,
    .editor-preview-panel {
        width: 100%;
    }

    .editor-form-panel {
        border-right: none;
        border-bottom: 1px solid var(--color-border-light);
        max-height: 50vh;
    }

    .editor-preview-panel {
        min-height: 50vh;
    }
}
