/**
 * NorCemic Shared Styles
 * Version: 2.1.0
 * Includes: Theme Toggle, Accessibility, Cookies, Chatbot
 * Updated: January 2025
 */

/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
    --norcemic-green: #2E8B2E;
    --norcemic-green-light: #4CAF4C;
    --norcemic-green-dark: #1B5E1B;
    --norcemic-orange: #F7931E;
    --norcemic-orange-light: #FFB347;
    --norcemic-orange-dark: #E07B00;
    --bg-primary: #FAFBFC;
    --bg-secondary: #F0F4F0;
    --bg-dark: #0D1F0D;
    --bg-card: #FFFFFF;
    --text-primary: #1A2E1A;
    --text-secondary: #4A5E4A;
    --text-muted: #6B7B6B;
    --text-inverse: #FFFFFF;
    --border-color: #D4E4D4;
    --shadow-sm: 0 2px 8px rgba(46, 139, 46, 0.08);
    --shadow-md: 0 8px 32px rgba(46, 139, 46, 0.12);
    --shadow-lg: 0 24px 64px rgba(46, 139, 46, 0.16);
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --font-size-base: 16px;
}

/* Dark Mode Variables */
[data-theme="dark"] {
    --bg-primary: #0D1F0D;
    --bg-secondary: #1A2E1A;
    --bg-dark: #050F05;
    --bg-card: #162616;
    --text-primary: #E8F5E8;
    --text-secondary: #B8D4B8;
    --text-muted: #8AAE8A;
    --text-inverse: #0D1F0D;
    --border-color: #2E4A2E;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.5);
}

/* High Contrast Mode */
[data-contrast="high"] {
    --text-primary: #000000;
    --text-secondary: #1A1A1A;
    --bg-primary: #FFFFFF;
    --bg-card: #FFFFFF;
    --border-color: #000000;
}

[data-theme="dark"][data-contrast="high"] {
    --text-primary: #FFFFFF;
    --text-secondary: #F0F0F0;
    --bg-primary: #000000;
    --bg-card: #0A0A0A;
    --border-color: #FFFFFF;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

[data-motion="reduced"] *, 
[data-motion="reduced"] *::before, 
[data-motion="reduced"] *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
}

/* ============================================
   COOKIES POPUP
   ============================================ */
.cookie-popup {
    position: fixed;
    bottom: -100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15);
    padding: 1.5rem 2rem;
    z-index: 9999;
    transition: bottom 0.5s ease-in-out;
}

.cookie-popup.active {
    bottom: 0;
}

.cookie-popup-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    flex-wrap: wrap;
}

.cookie-content {
    flex: 1;
    min-width: 300px;
}

.cookie-content h4 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.cookie-content h4 svg {
    width: 24px;
    height: 24px;
    stroke: var(--norcemic-orange);
}

.cookie-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

.cookie-content a {
    color: var(--norcemic-green);
    text-decoration: underline;
}

.cookie-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.cookie-btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: var(--transition-fast);
}

.cookie-btn-accept {
    background: var(--norcemic-green);
    color: white;
}

.cookie-btn-accept:hover {
    background: var(--norcemic-green-dark);
}

.cookie-btn-decline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.cookie-btn-decline:hover {
    border-color: var(--text-secondary);
}

.cookie-btn-settings {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.cookie-btn-settings:hover {
    background: var(--border-color);
}

/* Cookie Settings Modal */
.cookie-settings-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-fast);
    padding: 1rem;
}

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

.cookie-settings-content {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

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

.cookie-settings-header h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
}

.cookie-settings-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--bg-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cookie-settings-close svg {
    width: 20px;
    height: 20px;
    stroke: var(--text-secondary);
}

.cookie-settings-body {
    padding: 1.5rem;
}

.cookie-category {
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

.cookie-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.cookie-category h4 {
    font-size: 1rem;
    color: var(--text-primary);
}

.cookie-category p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.cookie-settings-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--border-color);
    border-radius: 26px;
    transition: var(--transition-fast);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: var(--transition-fast);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--norcemic-green);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(24px);
}

.toggle-switch input:disabled + .toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   CHATBOT WIDGET
   ============================================ */
.chatbot-widget {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9998;
}

.chatbot-trigger {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--norcemic-green), var(--norcemic-green-dark));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(46, 139, 46, 0.4);
    transition: var(--transition-fast);
    position: relative;
}

.chatbot-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(46, 139, 46, 0.5);
}

.chatbot-trigger svg {
    width: 28px;
    height: 28px;
    stroke: white;
    transition: var(--transition-fast);
}

.chatbot-trigger .chat-icon { display: block; }
.chatbot-trigger .close-icon { display: none; }

.chatbot-widget.active .chatbot-trigger .chat-icon { display: none; }
.chatbot-widget.active .chatbot-trigger .close-icon { display: block; }

.chatbot-pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--norcemic-green);
    animation: chatPulse 2s ease-out infinite;
}

@keyframes chatPulse {
    0% { transform: scale(1); opacity: 0.5; }
    100% { transform: scale(1.5); opacity: 0; }
}

.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 520px;
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: var(--transition-smooth);
    overflow: hidden;
}

.chatbot-widget.active .chatbot-window {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.chatbot-header {
    padding: 1.25rem;
    background: linear-gradient(135deg, var(--norcemic-green), var(--norcemic-green-dark));
    color: white;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chatbot-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-avatar svg {
    width: 28px;
    height: 28px;
    stroke: white;
}

.chatbot-info h4 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.chatbot-info p {
    font-size: 0.8rem;
    opacity: 0.9;
}

.chatbot-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chatbot-status::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ADE80;
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chatbot-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-message {
    max-width: 85%;
    padding: 0.875rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    line-height: 1.5;
}

.chat-message.bot {
    background: var(--bg-secondary);
    color: var(--text-primary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.chat-message.user {
    background: var(--norcemic-green);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chat-typing {
    display: flex;
    gap: 4px;
    padding: 0.875rem 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

.chat-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typingDot 1.4s ease-in-out infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

.chatbot-quick-replies {
    padding: 0 1rem 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.quick-reply {
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    font-size: 0.8rem;
    cursor: pointer;
    font-family: inherit;
    color: var(--text-primary);
    transition: var(--transition-fast);
}

.quick-reply:hover {
    background: var(--norcemic-green);
    color: white;
    border-color: var(--norcemic-green);
}

.chatbot-input {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.75rem;
}

.chatbot-input input {
    flex: 1;
    padding: 0.875rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.chatbot-input input:focus {
    outline: none;
    border-color: var(--norcemic-green);
}

.chatbot-send {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--norcemic-green);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.chatbot-send:hover {
    background: var(--norcemic-green-dark);
}

.chatbot-send svg {
    width: 20px;
    height: 20px;
    stroke: white;
}

/* ============================================
   ACCESSIBILITY PANEL
   ============================================ */
.accessibility-panel {
    position: fixed;
    top: 100px;
    right: -350px;
    width: 320px;
    background: var(--bg-card);
    border-radius: var(--radius-xl) 0 0 var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    border-right: none;
    z-index: 9997;
    transition: right var(--transition-smooth);
    overflow: hidden;
}

.accessibility-panel.active {
    right: 0;
}

.accessibility-header {
    padding: 1.25rem;
    background: linear-gradient(135deg, var(--norcemic-green), var(--norcemic-green-dark));
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.accessibility-header h4 {
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.accessibility-header svg {
    width: 20px;
    height: 20px;
}

.accessibility-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.accessibility-close svg {
    width: 16px;
    height: 16px;
    stroke: white;
}

.accessibility-body {
    padding: 1.25rem;
    max-height: 60vh;
    overflow-y: auto;
}

.accessibility-section {
    margin-bottom: 1.5rem;
}

.accessibility-section:last-child {
    margin-bottom: 0;
}

.accessibility-section h5 {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.75rem;
}

.accessibility-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

.accessibility-option:last-child {
    margin-bottom: 0;
}

.accessibility-option span {
    font-size: 0.9rem;
    color: var(--text-primary);
}

/* Font Size Controls */
.font-size-controls {
    display: flex;
    gap: 0.5rem;
}

.font-size-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-primary);
    font-family: inherit;
    transition: var(--transition-fast);
}

.font-size-btn:hover {
    background: var(--norcemic-green);
    color: white;
    border-color: var(--norcemic-green);
}

.font-size-btn.active {
    background: var(--norcemic-green);
    color: white;
    border-color: var(--norcemic-green);
}

.accessibility-reset {
    width: 100%;
    padding: 0.875rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition-fast);
}

.accessibility-reset:hover {
    background: var(--norcemic-orange);
    color: white;
    border-color: var(--norcemic-orange);
}

/* ============================================
   THEME TOGGLE
   ============================================ */
.theme-toggle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background: var(--bg-card);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.theme-toggle:hover {
    border-color: var(--norcemic-green);
    background: var(--bg-secondary);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    stroke: var(--text-secondary);
    transition: var(--transition-fast);
}

.theme-toggle:hover svg {
    stroke: var(--norcemic-green);
}

.theme-toggle .sun-icon { display: none; }
.theme-toggle .moon-icon { display: block; }

[data-theme="dark"] .theme-toggle .sun-icon { display: block; }
[data-theme="dark"] .theme-toggle .moon-icon { display: none; }

/* Accessibility Toggle Button */
.accessibility-toggle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background: var(--bg-card);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.accessibility-toggle:hover {
    border-color: var(--norcemic-green);
    background: var(--bg-secondary);
}

.accessibility-toggle svg {
    width: 20px;
    height: 20px;
    stroke: var(--text-secondary);
}

.accessibility-toggle:hover svg {
    stroke: var(--norcemic-green);
}

/* ============================================
   SKIP LINK - ACCESSIBILITY
   ============================================ */
.skip-link {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--norcemic-green);
    color: white;
    padding: 1rem 2rem;
    border-radius: var(--radius-md);
    z-index: 10000;
    font-weight: 600;
    transition: top var(--transition-fast);
    text-decoration: none;
}

.skip-link:focus {
    top: 10px;
    outline: 3px solid var(--norcemic-orange);
    outline-offset: 2px;
}

/* ============================================
   RESPONSIVE STYLES
   ============================================ */
@media (max-width: 768px) {
    .chatbot-window {
        width: calc(100vw - 2rem);
        right: -1rem;
        height: 450px;
    }
    
    .accessibility-panel {
        width: 100%;
        right: -100%;
        border-radius: 0;
    }
    
    .cookie-popup-inner {
        flex-direction: column;
        text-align: center;
    }
    
    .cookie-buttons {
        justify-content: center;
    }
    
    .chatbot-widget {
        bottom: 1rem;
        right: 1rem;
    }
    
    .chatbot-trigger {
        width: 56px;
        height: 56px;
    }
}

@media (max-width: 480px) {
    .chatbot-widget {
        bottom: 1rem;
        right: 1rem;
    }
    
    .chatbot-trigger {
        width: 56px;
        height: 56px;
    }
}
