/**
 * WCMS Product Suite - Common Styles
 * Shared design tokens and base components
 */

/* ========================================
   Design Tokens (CSS Custom Properties)
   ======================================== */

:root {
    /* Gray Scale (unified from slate) */
    --wcms-gray-50: #f8fafc;
    --wcms-gray-100: #f1f5f9;
    --wcms-gray-200: #e2e8f0;
    --wcms-gray-300: #cbd5e1;
    --wcms-gray-400: #94a3b8;
    --wcms-gray-500: #64748b;
    --wcms-gray-600: #475569;
    --wcms-gray-700: #334155;
    --wcms-gray-800: #1e293b;
    --wcms-gray-900: #0f172a;

    /* Brand Colors */
    --wcms-brand-primary: #ab8e66;
    --wcms-brand-primary-hover: #967d59;
    --wcms-brand-blue: #1DA1F2;

    /* Status Colors */
    --wcms-success: #10b981;
    --wcms-success-light: #ecfdf5;
    --wcms-warning: #f59e0b;
    --wcms-warning-light: #fffbeb;
    --wcms-error: #ef4444;
    --wcms-error-light: #fef2f2;
    --wcms-info: #3b82f6;
    --wcms-info-light: #eff6ff;

    /* Theme Colors - Rose */
    --wcms-rose-50: #fff1f2;
    --wcms-rose-100: #ffe4e6;
    --wcms-rose-200: #fecdd3;
    --wcms-rose-300: #fda4af;
    --wcms-rose-400: #fb7185;
    --wcms-rose-500: #f43f5e;
    --wcms-rose-600: #e11d48;

    /* Theme Colors - Indigo */
    --wcms-indigo-50: #eef2ff;
    --wcms-indigo-100: #e0e7ff;
    --wcms-indigo-200: #c7d2fe;
    --wcms-indigo-300: #a5b4fc;
    --wcms-indigo-400: #818cf8;
    --wcms-indigo-500: #6366f1;
    --wcms-indigo-600: #4f46e5;

    /* Theme Colors - Sky */
    --wcms-sky-50: #f0f9ff;
    --wcms-sky-100: #e0f2fe;
    --wcms-sky-200: #bae6fd;
    --wcms-sky-300: #7dd3fc;
    --wcms-sky-400: #38bdf8;
    --wcms-sky-500: #0ea5e9;
    --wcms-sky-600: #0284c7;

    /* Theme Colors - Emerald */
    --wcms-emerald-50: #ecfdf5;
    --wcms-emerald-100: #d1fae5;
    --wcms-emerald-200: #a7f3d0;
    --wcms-emerald-300: #6ee7b7;
    --wcms-emerald-400: #34d399;
    --wcms-emerald-500: #10b981;
    --wcms-emerald-600: #059669;

    /* Shadows */
    --wcms-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --wcms-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --wcms-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --wcms-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --wcms-shadow-card: 0 4px 60px rgba(0, 0, 0, 0.08);
    --wcms-shadow-soft: 0 10px 40px -3px rgba(0, 0, 0, 0.05);

    /* Spacing */
    --wcms-spacing-xs: 0.25rem;
    --wcms-spacing-sm: 0.5rem;
    --wcms-spacing-md: 1rem;
    --wcms-spacing-lg: 1.5rem;
    --wcms-spacing-xl: 2rem;
    --wcms-spacing-2xl: 3rem;

    /* Border Radius */
    --wcms-radius-sm: 0.375rem;
    --wcms-radius-md: 0.5rem;
    --wcms-radius-lg: 0.75rem;
    --wcms-radius-xl: 1rem;
    --wcms-radius-2xl: 1.5rem;
    --wcms-radius-full: 9999px;

    /* Transitions */
    --wcms-transition-fast: 150ms ease;
    --wcms-transition-base: 200ms ease;
    --wcms-transition-slow: 300ms ease;

    /* Z-Index Scale */
    --wcms-z-dropdown: 100;
    --wcms-z-modal: 1000;
    --wcms-z-toast: 1100;
}

/* ========================================
   Base Components
   ======================================== */

/* Card */
.wcms-card {
    background: var(--wcms-gray-50);
    border: 1px solid var(--wcms-gray-200);
    border-radius: var(--wcms-radius-xl);
    padding: var(--wcms-spacing-lg);
}

.wcms-card-white {
    background: #fff;
}

/* Buttons */
.wcms-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--wcms-spacing-sm);
    font-size: 0.875rem;
    font-weight: 500;
    padding: var(--wcms-spacing-sm) var(--wcms-spacing-md);
    border-radius: var(--wcms-radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--wcms-transition-base);
    text-decoration: none;
    line-height: 1.5;
}

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

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

.wcms-btn-primary:hover:not(:disabled) {
    background: var(--wcms-brand-primary-hover);
}

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

.wcms-btn-secondary:hover:not(:disabled) {
    background: var(--wcms-gray-200);
}

.wcms-btn-ghost {
    background: transparent;
    color: var(--wcms-gray-600);
}

.wcms-btn-ghost:hover:not(:disabled) {
    background: var(--wcms-gray-100);
    color: var(--wcms-gray-800);
}

.wcms-btn-icon {
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border-radius: var(--wcms-radius-lg);
    background: transparent;
    color: var(--wcms-gray-500);
    border: none;
    cursor: pointer;
    transition: all var(--wcms-transition-fast);
}

.wcms-btn-icon:hover:not(:disabled) {
    background: var(--wcms-gray-100);
    color: var(--wcms-gray-700);
}

.wcms-btn-sm {
    padding: var(--wcms-spacing-xs) var(--wcms-spacing-sm);
    font-size: 0.75rem;
}

.wcms-btn-lg {
    padding: var(--wcms-spacing-md) var(--wcms-spacing-lg);
    font-size: 1rem;
}

/* ========================================
   Toast Notification
   ======================================== */

.wcms-toast {
    position: fixed !important;
    bottom: 2rem !important;
    left: 50% !important;
    right: auto !important;
    top: auto !important;
    transform: translateX(-50%) translateY(100px) !important;
    background: var(--wcms-gray-800) !important;
    color: #fff !important;
    padding: var(--wcms-spacing-sm) var(--wcms-spacing-lg) !important;
    border-radius: var(--wcms-radius-full) !important;
    font-size: 0.875rem !important;
    font-weight: 500 !important;
    z-index: 999999 !important;
    opacity: 0 !important;
    visibility: hidden !important;
    transition: all 0.3s ease !important;
    box-shadow: var(--wcms-shadow-lg) !important;
    max-width: 90% !important;
    width: max-content;
    min-width: 200px;
    text-align: center !important;
    line-height: 1.5 !important;
    border: none !important;
    margin: 0 !important;
}

.wcms-toast.visible {
    transform: translateX(-50%) translateY(0) !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.wcms-toast.success {
    background: var(--wcms-success) !important;
}

.wcms-toast.error {
    background: var(--wcms-error) !important;
}

.wcms-toast.warning {
    background: var(--wcms-warning) !important;
}

.wcms-toast.info {
    background: var(--wcms-info) !important;
}

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

.wcms-modal {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 100000 !important;
    padding: 2rem 1rem !important;
    direction: rtl;
}

.wcms-modal.active {
    display: flex !important;
}

.wcms-modal .wcms-modal-overlay {
    position: absolute !important;
    inset: 0 !important;
    background: rgba(15, 23, 42, 0.55) !important;
    backdrop-filter: blur(6px) !important;
    opacity: 0 !important;
    visibility: hidden !important;
    transition: opacity var(--wcms-transition-base), visibility var(--wcms-transition-base) !important;
}

.wcms-modal.active .wcms-modal-overlay {
    opacity: 1 !important;
    visibility: visible !important;
}

.wcms-modal-content {
    position: relative !important;
    background: #fff !important;
    border-radius: 28px !important;
    width: min(420px, 90vw) !important;
    padding: 2.5rem 2.25rem 2rem !important;
    text-align: center !important;
    box-shadow: 0 25px 65px rgba(15, 23, 42, 0.12) !important;
    opacity: 0 !important;
    transform: translateY(20px) scale(0.98) !important;
    transition: all 220ms ease !important;
    z-index: 1 !important;
}

.wcms-modal.active .wcms-modal-content {
    opacity: 1 !important;
    transform: translateY(0) scale(1) !important;
}

.wcms-modal-icon {
    width: 72px !important;
    height: 72px !important;
    border-radius: 9999px !important;
    background: #fbf6ef !important;
    margin: 0 auto 1rem !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #a67a4e !important;
}

.wcms-modal-header {
    margin-bottom: 0.5rem !important;
}

.wcms-modal-title {
    font-size: 1.3rem !important;
    font-weight: 700 !important;
    color: #1f2937 !important;
    margin: 0 !important;
}

.wcms-modal-close {
    position: absolute !important;
    top: 1rem !important;
    left: 1rem !important;
    right: auto !important;
    width: 36px !important;
    padding: 0px !important; ;
    height: 36px !important;
    border-radius: 10px !important;
    border: none !important;
    background: var(--wcms-gray-100) !important;
    color: var(--wcms-gray-700) !important;
    border: 1px solid var(--wcms-gray-200) !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background var(--wcms-transition-fast), color var(--wcms-transition-fast) !important;
    z-index: 10 !important;
}

/* Ensure close icon SVG is visible even if theme applies global svg rules */
.wcms-modal-close svg {
    width: 18px !important;
    height: 18px !important;
    display: block !important;
    fill: none !important;
    stroke: currentColor !important;
}

.wcms-modal-close svg * {
    fill: none !important;
    stroke: currentColor !important;
}

.wcms-modal-close:hover {
    background: var(--wcms-gray-200) !important;
    color: var(--wcms-gray-900) !important;
}

.wcms-modal-body {
    color: #6b7280 !important;
    font-size: 0.95rem !important;
    line-height: 1.7 !important;
    margin-bottom: 1.5rem !important;
}

.wcms-modal-footer {
    display: flex !important;
    gap: 0.75rem !important;
    width: 100% !important;
}

.wcms-modal .wcms-btn {
    flex: 1 !important;
    border-radius: 14px !important;
    padding: 0.85rem 1rem !important;
    font-size: 0.95rem !important;
    font-weight: 600 !important;
}

.wcms-modal .wcms-btn-primary {
    background: #a67a4e !important;
    color: #fff !important;
    border: none !important;
}

.wcms-modal .wcms-btn-primary:hover {
    background: #8f673e !important;
}

.wcms-modal .wcms-btn-secondary {
    background: #f3f4f6 !important;
    color: #4b5563 !important;
    border: none !important;
}

.wcms-modal .wcms-btn-secondary:hover {
    background: #e5e7eb !important;
}

.wcms-login-modal .wcms-modal-footer .wcms-btn {
    width: 100%;
}

/* ========================================
   Form Elements
   ======================================== */

.wcms-input {
    display: block;
    width: 100%;
    padding: var(--wcms-spacing-sm) var(--wcms-spacing-md);
    font-size: 0.9375rem;
    color: var(--wcms-gray-900);
    background: #fff;
    border: 1px solid var(--wcms-gray-300);
    border-radius: var(--wcms-radius-md);
    transition: all var(--wcms-transition-fast);
}

.wcms-input:focus {
    outline: none;
    border-color: var(--wcms-brand-primary);
    box-shadow: 0 0 0 3px rgba(171, 142, 102, 0.1);
}

.wcms-input::placeholder {
    color: var(--wcms-gray-400);
}

.wcms-textarea {
    resize: vertical;
    min-height: 100px;
}

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

.wcms-spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--wcms-gray-200);
    border-top-color: var(--wcms-brand-primary);
    border-radius: 50%;
    animation: wcms-spin 0.8s linear infinite;
}

.wcms-spinner-sm {
    width: 1rem;
    height: 1rem;
}

.wcms-spinner-lg {
    width: 2rem;
    height: 2rem;
    border-width: 3px;
}

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

/* Loading Overlay */
.wcms-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: inherit;
}

/* ========================================
   Avatar
   ======================================== */

.wcms-avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--wcms-radius-full);
    background: var(--wcms-gray-200);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.wcms-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wcms-avatar-sm {
    width: 2rem;
    height: 2rem;
}

.wcms-avatar-lg {
    width: 3rem;
    height: 3rem;
}

.wcms-avatar-placeholder {
    font-size: 1rem;
    font-weight: 600;
    color: var(--wcms-gray-500);
}

/* ========================================
   Utility Classes
   ======================================== */

/* Display */
.wcms-flex { display: flex; }
.wcms-inline-flex { display: inline-flex; }
.wcms-block { display: block; }
.wcms-hidden { display: none; }

/* Flex Direction */
.wcms-flex-col { flex-direction: column; }
.wcms-flex-row { flex-direction: row; }

/* Flex Alignment */
.wcms-items-center { align-items: center; }
.wcms-items-start { align-items: flex-start; }
.wcms-items-end { align-items: flex-end; }
.wcms-justify-center { justify-content: center; }
.wcms-justify-between { justify-content: space-between; }
.wcms-justify-end { justify-content: flex-end; }

/* Flex Wrap */
.wcms-flex-wrap { flex-wrap: wrap; }

/* Gap */
.wcms-gap-xs { gap: var(--wcms-spacing-xs); }
.wcms-gap-sm { gap: var(--wcms-spacing-sm); }
.wcms-gap-md { gap: var(--wcms-spacing-md); }
.wcms-gap-lg { gap: var(--wcms-spacing-lg); }

/* Text Alignment */
.wcms-text-center { text-align: center; }
.wcms-text-right { text-align: right; }
.wcms-text-left { text-align: left; }

/* Text Size */
.wcms-text-xs { font-size: 0.75rem; }
.wcms-text-sm { font-size: 0.875rem; }
.wcms-text-base { font-size: 1rem; }
.wcms-text-lg { font-size: 1.125rem; }
.wcms-text-xl { font-size: 1.25rem; }

/* Text Weight */
.wcms-font-normal { font-weight: 400; }
.wcms-font-medium { font-weight: 500; }
.wcms-font-semibold { font-weight: 600; }
.wcms-font-bold { font-weight: 700; }

/* Text Color */
.wcms-text-gray-400 { color: var(--wcms-gray-400); }
.wcms-text-gray-500 { color: var(--wcms-gray-500); }
.wcms-text-gray-600 { color: var(--wcms-gray-600); }
.wcms-text-gray-700 { color: var(--wcms-gray-700); }
.wcms-text-gray-800 { color: var(--wcms-gray-800); }
.wcms-text-gray-900 { color: var(--wcms-gray-900); }

/* Margin */
.wcms-mt-xs { margin-top: var(--wcms-spacing-xs); }
.wcms-mt-sm { margin-top: var(--wcms-spacing-sm); }
.wcms-mt-md { margin-top: var(--wcms-spacing-md); }
.wcms-mt-lg { margin-top: var(--wcms-spacing-lg); }
.wcms-mb-xs { margin-bottom: var(--wcms-spacing-xs); }
.wcms-mb-sm { margin-bottom: var(--wcms-spacing-sm); }
.wcms-mb-md { margin-bottom: var(--wcms-spacing-md); }
.wcms-mb-lg { margin-bottom: var(--wcms-spacing-lg); }

/* Width */
.wcms-w-full { width: 100%; }

/* Position */
.wcms-relative { position: relative; }
.wcms-absolute { position: absolute; }
