/**
 * CM Core Library - Public Styles
 *
 * Compiled from SCSS to plain CSS.
 *
 * @package Codemoy\Core
 * @version 1.0.0
 */

/* ==========================================================================
   Keyframes
   ========================================================================== */

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

@keyframes cm-pulse-error {
    0% { box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2); }
    50% { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15); }
    100% { box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2); }
}

@keyframes cm-pulse-warning {
    0% { box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2); }
    50% { box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.15); }
    100% { box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2); }
}

@keyframes cm-pulse-success {
    0% { box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2); }
    50% { box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15); }
    100% { box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2); }
}

@keyframes cm-pulse-info {
    0% { box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2); }
    50% { box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15); }
    100% { box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2); }
}

/* ==========================================================================
   CSS Custom Properties
   ========================================================================== */

:root {
    /* Colors - Primary */
    --cmc-theme-primary: #2271b1;
    --cmc-theme-primary-hover: #135e96;
    --cmc-theme-primary-light: #72aee6;

    /* Colors - Status */
    --cmc-theme-success: #00a32a;
    --cmc-theme-success-light: #ecf7ed;
    --cmc-theme-success-dark: #00761a;
    --cmc-theme-error: #d63638;
    --cmc-theme-error-light: #fcf0f1;
    --cmc-theme-error-dark: #b32d2e;
    --cmc-theme-warning: #dba617;
    --cmc-theme-warning-light: #fcf9e8;
    --cmc-theme-warning-dark: #94660c;
    --cmc-theme-info: #2271b1;
    --cmc-theme-info-light: #f0f6fc;
    --cmc-theme-info-dark: #135e96;

    /* Colors - Neutral */
    --cmc-theme-text: #2c3338;
    --cmc-theme-text-muted: #646970;
    --cmc-theme-text-light: #666;
    --cmc-theme-text-lighter: #787c82;
    --cmc-theme-border: #dcdcde;
    --cmc-theme-border-light: #ddd;
    --cmc-theme-border-medium: #c3c4c7;
    --cmc-theme-border-section: #e2e4e7;
    --cmc-theme-bg-white: #fff;
    --cmc-theme-bg-gray: #f6f7f7;
    --cmc-theme-bg-gray-light: #f0f0f1;
    --cmc-theme-bg-off-white: #f8f9fa;
    --cmc-theme-bg-subtle: #f5f5f5;

    /* Colors - Badge */
    --cmc-theme-badge-success-bg: #d4edda;
    --cmc-theme-badge-success-text: #155724;
    --cmc-theme-badge-warning-bg: #fff3cd;
    --cmc-theme-badge-warning-text: #856404;
    --cmc-theme-badge-error-bg: #f8d7da;
    --cmc-theme-badge-error-text: #721c24;
    --cmc-theme-badge-info-bg: #d1ecf1;
    --cmc-theme-badge-info-text: #0c5460;
    --cmc-theme-badge-neutral-bg: #f0f0f1;
    --cmc-theme-badge-neutral-text: #50575e;

    /* Typography */
    --cmc-theme-font-size-base: 14px;
    --cmc-theme-font-size-small: 13px;
    --cmc-theme-font-size-large: 16px;
    --cmc-theme-font-weight-normal: 400;
    --cmc-theme-font-weight-semibold: 600;

    /* Spacing */
    --cmc-theme-space-xs: 5px;
    --cmc-theme-space-sm: 8px;
    --cmc-theme-space-md: 12px;
    --cmc-theme-space-lg: 15px;
    --cmc-theme-space-xl: 20px;
    --cmc-theme-space-2xl: 30px;

    /* Border Radius */
    --cmc-theme-radius-sm: 3px;
    --cmc-theme-radius-md: 4px;

    /* Shadows */
    --cmc-theme-shadow-light: 0 1px 1px rgba(0, 0, 0, 0.04);

    /* Transitions */
    --cmc-theme-transition-fast: 0.2s;
    --cmc-theme-transition-normal: 0.3s;

    /* Z-Index */
    --cmc-theme-z-overlay: 9999;

    /* Form Specific */
    --cmc-theme-input-padding: 10px 12px;
    --cmc-theme-input-height: 42px;
    --cmc-theme-form-max-width: 500px;

    /* Common Form Field Spacing */
    --cmc-theme-field-gap: 20px;
    --cmc-theme-label-gap: 8px;

    /* ── Input Field Design Tokens (shared across all plugins) ──
     * Use var(--cmc-input-bg) / var(--cmc-input-border) in all plugin input CSS.
     * --cmc-input-bg is slightly off-white to visually distinguish inputs
     * from the white page/card background.
     */
    --cmc-input-bg: color-mix(in srgb, var(--cmc-theme-text-color, #1a1a1a) 4%, var(--cmc-theme-background-color, #fff));
    --cmc-input-border: var(--cmc-theme-border-color, #dcdcde);
}

/* ==========================================================================
   Public Forms
   ========================================================================== */

.cm-form {
    max-width: 500px;
}

.cm-field {
    margin-bottom: 20px;
}

.cm-field-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.cm-field input[type="text"],
.cm-field input[type="email"],
.cm-field input[type="password"],
.cm-field textarea,
.cm-field select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--cmc-theme-border-light, #ddd);
    border-radius: var(--cmc-theme-radius-sm, 4px);
    font-size: var(--cmc-theme-font-size-base, 14px);
    transition: border-color var(--cmc-theme-transition-fast, 0.2s);
}

.cm-field input[type="text"]:focus,
.cm-field input[type="email"]:focus,
.cm-field input[type="password"]:focus,
.cm-field textarea:focus,
.cm-field select:focus {
    outline: none;
    border-color: var(--cmc-theme-primary, #2271b1);
}

.cm-field .description {
    margin-top: 5px;
    font-size: var(--cmc-theme-font-size-small, 13px);
    color: var(--cmc-theme-text-muted, #666);
}

.cm-field.error input,
.cm-field.error textarea,
.cm-field.error select {
    border-color: var(--cmc-theme-error, #d63638);
}

.cm-field-error {
    color: var(--cmc-theme-error, #d63638);
    font-size: 13px;
    margin-top: 5px;
}

.cm-field-checkbox label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.cm-field-checkbox input[type="checkbox"] {
    margin-right: 8px;
}

/* ==========================================================================
   Public Buttons
   ========================================================================== */

.cm-button {
    display: inline-block;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
    padding: 12px 24px;
    background: var(--cmc-theme-primary, #2271b1);
    color: var(--cmc-theme-bg-white, #fff);
    font-size: 16px;
}

.cm-button:hover {
    background: var(--cmc-theme-primary-hover, #135e96);
    color: var(--cmc-theme-bg-white, #fff);
}

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

.cm-button.secondary {
    background: var(--cmc-theme-bg-gray-light, #f0f0f1);
    color: var(--cmc-theme-text, #2c3338);
}

.cm-button.secondary:hover {
    background: var(--cmc-theme-border-light, #dcdcde);
}

/* ==========================================================================
   Public Alerts
   ========================================================================== */

.cm-alert {
    padding: 15px;
    margin: 15px 0;
    border-radius: 4px;
    border-left: 4px solid;
}

.cm-alert.success {
    border-left-color: var(--cmc-theme-success, #00a32a);
    background: var(--cmc-theme-success-light, #ecf7ed);
    color: var(--cmc-theme-success-dark, #00761a);
}

.cm-alert.error {
    border-left-color: var(--cmc-theme-error, #d63638);
    background: var(--cmc-theme-error-light, #fcf0f1);
    color: var(--cmc-theme-error-dark, #b32d2e);
}

.cm-alert.warning {
    border-left-color: var(--cmc-theme-warning, #dba617);
    background: var(--cmc-theme-warning-light, #fcf9e8);
    color: var(--cmc-theme-warning-dark, #94660c);
}

.cm-alert.info {
    border-left-color: var(--cmc-theme-info, #2271b1);
    background: var(--cmc-theme-info-light, #f0f6fc);
    color: var(--cmc-theme-info-dark, #135e96);
}

/* ==========================================================================
   Loading Spinner
   ========================================================================== */

.cm-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--cmc-theme-primary, #2271b1);
    border-radius: 50%;
    animation: cm-spin 0.6s linear infinite;
}

/* ==========================================================================
   Loading Overlay
   ========================================================================== */

.cm-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.cm-loading-overlay .cm-spinner {
    width: 40px;
    height: 40px;
    border-width: 4px;
    border-top-color: var(--cmc-theme-bg-white, #fff);
}

/* ==========================================================================
   Search Box Component
   ========================================================================== */

.cm-search-wrapper {
    margin-bottom: 16px;
    width: 100%;
}

.cm-search-box {
    position: relative;
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, var(--cmc-theme-bg-off-white, #f8f9fa) 0%, var(--cmc-theme-bg-white, #ffffff) 100%);
    border: 2px solid var(--cmc-theme-border-light, #e2e8f0);
    border-radius: 8px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.cm-search-box:focus-within {
    border-color: var(--cmc-theme-primary, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.cm-search-icon {
    position: absolute;
    left: 14px;
    color: var(--cmc-theme-text-muted, #64748b);
    font-size: 18px;
    width: 18px;
    height: 18px;
    pointer-events: none;
    z-index: 1;
}

.cm-search-input {
    width: 100%;
    padding: 14px 14px 14px 44px;
    border: none;
    background: transparent;
    font-size: 15px;
    line-height: 1.5;
    color: var(--cmc-theme-text, #1e293b);
    outline: none;
}

.cm-search-input::placeholder {
    color: var(--cmc-theme-text-lighter, #94a3b8);
}

.cm-search-guidance {
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--cmc-theme-text-muted, #475569);
    font-weight: 500;
    padding-left: 2px;
}

.cm-search-box.cm-theme-default {
    background: inherit;
    border: 1px solid;
    border-color: inherit;
    border-radius: 4px;
}

.cm-search-box.cm-theme-default .cm-search-input {
    color: inherit;
}

.cm-search-box.cm-theme-default .cm-search-icon {
    color: inherit;
    opacity: 0.5;
}

@media screen and (max-width: 768px) {
    .cm-search-input {
        padding: 12px 12px 12px 40px;
        font-size: 14px;
    }

    .cm-search-icon {
        left: 12px;
        font-size: 16px;
        width: 16px;
        height: 16px;
    }
}

/* ==========================================================================
   Field Feedback Component
   ========================================================================== */

.cm-needs-input {
    border-color: var(--cmc-theme-error, #ef4444) !important;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2) !important;
}

.cm-needs-input-animate {
    animation: cm-pulse-error 1s ease-in-out 2;
}

.cm-warning-animate {
    animation: cm-pulse-warning 1s ease-in-out 2;
}

.cm-success-animate {
    animation: cm-pulse-success 1s ease-in-out 2;
}

.cm-info-animate {
    animation: cm-pulse-info 1s ease-in-out 2;
}

.cm-field-warning {
    border-color: var(--cmc-theme-warning, #f59e0b) !important;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2) !important;
}

.cm-field-success {
    border-color: var(--cmc-theme-success, #10b981) !important;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2) !important;
}

.cm-field-info {
    border-color: var(--cmc-theme-info, #3b82f6) !important;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2) !important;
}

.cm-field-hint {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    font-weight: 500;
}

.cm-field-hint.cm-hint-error,
.cm-manual-hint {
    color: var(--cmc-theme-error, #dc2626);
}

.cm-field-hint.cm-hint-warning {
    color: var(--cmc-theme-warning-dark, #d97706);
}

.cm-field-hint.cm-hint-success {
    color: var(--cmc-theme-success-dark, #059669);
}

.cm-field-hint.cm-hint-info {
    color: var(--cmc-theme-info, #2563eb);
}

/* ==========================================================================
   Autocomplete Dropdown Component
   ========================================================================== */

.pac-container {
    z-index: 100000 !important;
    font-family: inherit;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    background: #ffffff;
}

.pac-item {
    padding: 8px 12px;
    cursor: pointer;
    line-height: 1.5;
}

.pac-item:hover {
    background-color: #f7f7f7;
}

.pac-item-query {
    font-size: 14px;
}

.pac-matched {
    font-weight: 600;
}

.pac-target-input::placeholder {
    color: transparent !important;
}

.cm-autocomplete-dropdown {
    position: absolute;
    z-index: 100000;
    background: var(--cmc-theme-bg-white, #ffffff);
    border-radius: var(--cmc-theme-radius-sm, 4px);
    box-shadow: var(--cmc-theme-shadow-light, 0 2px 6px rgba(0, 0, 0, 0.15));
    max-height: 300px;
    overflow-y: auto;
    width: 100%;
}

.cm-autocomplete-item {
    padding: 8px 12px;
    cursor: pointer;
    line-height: 1.5;
    font-size: 14px;
    border-bottom: 1px solid var(--cmc-theme-border-light, #f0f0f0);
}

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

.cm-autocomplete-item:hover,
.cm-autocomplete-item.cm-active {
    background-color: #f7f7f7;
}

.cm-autocomplete-item.cm-selected {
    background-color: #e8f4fd;
}

.cm-autocomplete-match {
    font-weight: 600;
    color: var(--cmc-theme-text, #1a1a1a);
}

.cm-autocomplete-secondary {
    font-size: 12px;
    color: var(--cmc-theme-text-muted, #666);
    margin-top: 2px;
}

.cm-autocomplete-loading {
    padding: 8px 12px;
    text-align: center;
    color: var(--cmc-theme-text-muted, #666);
}

.cm-autocomplete-loading::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--cmc-theme-border-light, #e0e0e0);
    border-top-color: var(--cmc-theme-text-muted, #666);
    border-radius: 50%;
    animation: cm-spin 0.8s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

.cm-autocomplete-empty {
    padding: 8px 12px;
    text-align: center;
    color: var(--cmc-theme-text-lighter, #999);
    font-style: italic;
}

/* ==========================================================================
   Modal
   ========================================================================== */

.cm-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 999999;
}

.cm-modal--active {
    visibility: visible;
    opacity: 1;
}

body.cm-modal-open {
    overflow: hidden;
}

.cm-modal__backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.cm-modal__dialog {
    position: relative;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    background: var(--cmc-theme-bg-white, #fff);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    transform: translateY(20px);
    transition: transform 0.2s ease;
}

.cm-modal--active .cm-modal__dialog {
    transform: translateY(0);
}

.cm-modal--sm .cm-modal__dialog {
    max-width: 360px;
}

.cm-modal--lg .cm-modal__dialog {
    max-width: 720px;
}

.cm-modal__content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: inherit;
}

.cm-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--cmc-theme-border-light, #e5e7eb);
    flex-shrink: 0;
}

.cm-modal__title {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: var(--cmc-theme-text, #1f2937);
    line-height: 1.4;
}

.cm-modal__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: none;
    font-size: 22px;
    color: var(--cmc-theme-text-lighter, #9ca3af);
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.cm-modal__close:hover {
    background: var(--cmc-theme-bg-gray-light, #f3f4f6);
    color: var(--cmc-theme-text, #374151);
}

.cm-modal__body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.cm-modal__footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 14px 20px;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}

@media (max-width: 480px) {
    .cm-modal__dialog {
        width: 95%;
        max-height: 85vh;
    }

    .cm-modal__header {
        padding: 14px 16px;
    }

    .cm-modal__body {
        padding: 16px;
    }

    .cm-modal__footer {
        padding: 12px 16px;
    }
}

/* ==========================================================================
   Step Flow Component
   ========================================================================== */

.cm-step-flow {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    padding: 0;
    list-style: none;
    gap: 0;
}

.cm-step-flow__item {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.cm-step-flow__number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
    transition: background 0.3s, color 0.3s, border-color 0.3s;
    background: var(--cmc-theme-bg-gray-light, #f0f0f1);
    color: var(--cmc-theme-text-muted, #646970);
    border: 2px solid var(--cmc-theme-border, #dcdcde);
}

.cm-step-flow__label {
    font-size: 13px;
    font-weight: 500;
    color: var(--cmc-theme-text-muted, #646970);
    transition: color 0.3s;
    white-space: nowrap;
}

.cm-step-flow__connector {
    width: 32px;
    height: 2px;
    background: var(--cmc-theme-border, #dcdcde);
    margin: 0 8px;
    flex-shrink: 0;
    transition: background 0.3s;
}

/* Active step */
.cm-step-flow__item--active .cm-step-flow__number {
    background: var(--cmc-plugin-primary, var(--cmc-theme-primary, #2271b1));
    color: #fff;
    border-color: var(--cmc-plugin-primary, var(--cmc-theme-primary, #2271b1));
}

.cm-step-flow__item--active .cm-step-flow__label {
    color: var(--cmc-plugin-primary, var(--cmc-theme-primary, #2271b1));
    font-weight: 600;
}

/* Completed step */
.cm-step-flow__item--completed .cm-step-flow__number {
    background: var(--cmc-theme-success, #00a32a);
    color: #fff;
    border-color: var(--cmc-theme-success, #00a32a);
}

.cm-step-flow__item--completed .cm-step-flow__label {
    color: var(--cmc-theme-text, #2c3338);
}

.cm-step-flow__connector--completed {
    background: var(--cmc-theme-success, #00a32a);
}

/* Mobile: hide labels, show only numbers */
@media (max-width: 480px) {
    .cm-step-flow__label {
        display: none;
    }

    .cm-step-flow__connector {
        width: 24px;
        margin: 0 4px;
    }
}

/* ==========================================================================
   Button Styles — Use Plugin Primary Color
   ========================================================================== */

.button,
.wp-element-button {
    background-color: var(--cmc-plugin-primary, var(--cmc-theme-primary, #2271b1));
    color: var(--cmc-theme-button-text-color, #fff);
    border-color: var(--cmc-plugin-primary, var(--cmc-theme-primary, #2271b1));
    cursor: pointer;
}

.button:hover,
.wp-element-button:hover {
    background-color: var(--cmc-theme-secondary-color, color-mix(in srgb, var(--cmc-plugin-primary, var(--cmc-theme-primary, #2271b1)) 85%, #000));
    border-color: var(--cmc-theme-secondary-color, color-mix(in srgb, var(--cmc-plugin-primary, var(--cmc-theme-primary, #2271b1)) 85%, #000));
}

.button:focus,
.wp-element-button:focus {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--cmc-plugin-primary, var(--cmc-theme-primary, #2271b1)) 15%, transparent);
}

.button.alt,
.wp-element-button[aria-pressed="true"] {
    background-color: var(--cmc-plugin-primary, var(--cmc-theme-primary, #2271b1));
    border-color: var(--cmc-plugin-primary, var(--cmc-theme-primary, #2271b1));
}
