/* Servanda Theme System
   "Pacta Sunt Servanda" - Agreements Must Be Kept

   Themes:
   - modern: Current clean look (default)
   - classical: Roman/legal inspired with serif fonts
   - parchment: Warm, aged document aesthetic
   - dark-counsel: Sophisticated dark mode with gold accents
*/

/* ==================== CSS Variables ==================== */
:root {
    /* Modern Theme (default) - Brick & Mustard */
    --bg-primary: #fdfcfb;
    --bg-secondary: #ffffff;
    --bg-tertiary: #faf6f4;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --accent-primary: #b85c38;
    --accent-secondary: #a34f2e;
    --accent-light: #faf6f4;
    --accent-mustard: #c9a227;
    --accent-mustard-light: #faf8f0;
    --border-color: #e5e7eb;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --nav-bg: #fdfcfb;
    --nav-border: rgba(184, 92, 56, 0.1);
    --button-text: #ffffff;
    --font-heading: 'Playfair Display', Georgia, serif;
    --font-body: 'Inter', system-ui, sans-serif;
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
}

/* Classical Theme - Claude/Anthropic inspired */
[data-theme="classical"] {
    --bg-primary: #f9f7f4;
    --bg-secondary: #fffefa;
    --bg-tertiary: #f0ebe4;
    --text-primary: #1a1915;
    --text-secondary: #4a4640;
    --text-muted: #7a756d;
    --accent-primary: #da7756;  /* Claude terra cotta */
    --accent-secondary: #c56a4a;
    --accent-light: #fef3ef;
    --border-color: #e5ddd3;
    --shadow-color: rgba(50, 40, 30, 0.1);
    --nav-bg: #fffefa;
    --nav-border: #e5ddd3;
    --button-text: #ffffff;
    --font-heading: 'Libre Baskerville', Georgia, 'Times New Roman', serif;
    --font-body: 'Libre Baskerville', ui-serif, Georgia, Cambria, 'Times New Roman', Times, serif;
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
}

/* Parchment Theme - Aged Document */
[data-theme="parchment"] {
    --bg-primary: #f4ede4;
    --bg-secondary: #faf6f0;
    --bg-tertiary: #ebe3d6;
    --text-primary: #2c241c;
    --text-secondary: #4a4035;
    --text-muted: #7a6f62;
    --accent-primary: #6b4423;
    --accent-secondary: #8b5a2b;
    --accent-light: #f0e6d8;
    --border-color: #d4c4a8;
    --shadow-color: rgba(60, 40, 20, 0.15);
    --nav-bg: #f8f2e8;
    --nav-border: #d4c4a8;
    --button-text: #faf6f0;
    --font-heading: 'Cormorant Garamond', 'Palatino', serif;
    --font-body: 'Crimson Text', 'Book Antiqua', serif;
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
}

/* Dark Counsel Theme - Sophisticated Dark */
[data-theme="dark-counsel"] {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #252525;
    --text-primary: #f5f5f5;
    --text-secondary: #a3a3a3;
    --text-muted: #737373;
    --accent-primary: #c9a227;
    --accent-secondary: #ddb832;
    --accent-light: #2a2515;
    --border-color: #333333;
    --shadow-color: rgba(0, 0, 0, 0.4);
    --nav-bg: #141414;
    --nav-border: #2a2a2a;
    --button-text: #0f0f0f;
    --font-heading: 'Cinzel', 'Times New Roman', serif;
    --font-body: 'Inter', system-ui, sans-serif;
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
}

/* ==================== Base Styles ==================== */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Navigation theming */
.themed-nav {
    background-color: var(--nav-bg);
    border-color: var(--nav-border);
}

.themed-nav .nav-brand {
    color: var(--accent-primary);
    font-family: var(--font-heading);
}

.themed-nav a {
    color: var(--text-secondary);
}

.themed-nav a:hover {
    color: var(--text-primary);
}

/* Card theming */
.themed-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 3px var(--shadow-color);
}

/* Button theming */
.themed-btn-primary {
    background-color: var(--accent-primary);
    color: var(--button-text);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    transition: background-color 0.2s ease;
}

.themed-btn-primary:hover {
    background-color: var(--accent-secondary);
}

.themed-btn-secondary {
    background-color: var(--bg-secondary);
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
    border-radius: var(--radius-md);
}

.themed-btn-secondary:hover {
    background-color: var(--accent-light);
}

/* Text theming */
.themed-heading {
    font-family: var(--font-heading);
    color: var(--text-primary);
}

.themed-text {
    color: var(--text-secondary);
}

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

/* Input theming */
.themed-input {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
}

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

/* Feature card icons */
.themed-icon-bg {
    background-color: var(--accent-light);
}

.themed-icon {
    color: var(--accent-primary);
}

/* ==================== Sans-serif override for UI elements ==================== */
.sans-serif,
.user-dropdown-name,
.user-dropdown-email,
.nav-login-btn {
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
}

/* ==================== Theme Switcher Styles ==================== */
.theme-switcher {
    position: relative;
    display: inline-block;
}

/* Icon-only theme button */
.theme-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background-color: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-icon-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--accent-primary);
}

.theme-switcher-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.theme-switcher-btn:hover {
    background-color: var(--bg-secondary);
    border-color: var(--accent-primary);
}

.theme-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 180px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 12px var(--shadow-color);
    z-index: 50;
    display: none;
}

.theme-dropdown.active {
    display: block;
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    text-align: left;
    transition: background-color 0.15s ease;
}

.theme-option:first-child {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.theme-option:last-child {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.theme-option:hover {
    background-color: var(--accent-light);
}

.theme-option.active {
    background-color: var(--accent-light);
    color: var(--accent-primary);
    font-weight: 500;
}

.theme-option-icon {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    border: 2px solid var(--border-color);
}

.theme-option-icon.modern { background: linear-gradient(135deg, #b85c38, #c9a227); }
.theme-option-icon.classical { background: linear-gradient(135deg, #da7756, #f9f7f4); }
.theme-option-icon.parchment { background: linear-gradient(135deg, #6b4423, #f4ede4); }
.theme-option-icon.dark-counsel { background: linear-gradient(135deg, #c9a227, #1a1a1a); }

/* ==================== Classical Theme Decorations ==================== */
[data-theme="classical"] .classical-decoration {
    display: block;
}

.classical-decoration {
    display: none;
}

/* Roman column divider */
.classical-divider {
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--border-color), transparent);
    margin: 2rem 0;
}

/* Laurel wreath decoration (via before/after) */
[data-theme="classical"] .laurel-wrap::before {
    content: "⚖️";
    margin-right: 0.5rem;
}

/* ==================== Parchment Theme Decorations ==================== */
[data-theme="parchment"] .themed-card {
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
}

[data-theme="parchment"] .parchment-seal {
    display: inline-block;
}

.parchment-seal {
    display: none;
}

/* ==================== Dark Counsel Decorations ==================== */
[data-theme="dark-counsel"] .themed-card {
    border: 1px solid #2a2515;
    box-shadow: 0 0 20px rgba(201, 162, 39, 0.1);
}

[data-theme="dark-counsel"] .themed-btn-primary {
    background: linear-gradient(135deg, #c9a227, #a88420);
    box-shadow: 0 2px 10px rgba(201, 162, 39, 0.3);
}

[data-theme="dark-counsel"] .accent-glow {
    text-shadow: 0 0 10px rgba(201, 162, 39, 0.5);
}

/* ==================== Chat Styles (all themes) ==================== */
.chat-scroll::-webkit-scrollbar {
    width: 6px;
}

.chat-scroll::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

.chat-scroll::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

/* ==================== Latin Motto Styling ==================== */
.motto {
    font-family: var(--font-heading);
    font-style: italic;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

[data-theme="classical"] .motto,
[data-theme="parchment"] .motto {
    font-weight: 500;
}

/* ==================== Transition for theme changes ==================== */
* {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.15s ease;
}

/* Disable transitions on initial load */
.no-transitions * {
    transition: none !important;
}

/* ==================== User Menu Styles ==================== */
.user-menu {
    position: relative;
    display: inline-block;
}

.user-avatar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--accent-primary);
    color: var(--button-text);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.user-avatar-btn:hover .user-avatar {
    transform: scale(1.05);
    box-shadow: 0 2px 8px var(--shadow-color);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 220px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 16px var(--shadow-color);
    z-index: 50;
    display: none;
}

.user-dropdown.active {
    display: block;
}

.user-dropdown-header {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.user-dropdown-name {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9375rem;
    line-height: 1.4;
}

.user-dropdown-email {
    display: block;
    color: var(--text-muted);
    font-size: 0.8125rem;
    line-height: 1.4;
    word-break: break-all;
}

.user-dropdown-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 0;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.875rem;
    text-decoration: none;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.user-dropdown-item:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.user-dropdown-logout {
    color: #dc2626;
}

.user-dropdown-logout:hover {
    background-color: #fef2f2;
    color: #b91c1c;
}

[data-theme="dark-counsel"] .user-dropdown-logout:hover {
    background-color: #2a1515;
    color: #f87171;
}

/* Sign in button for logged out state */
.nav-login-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background-color: var(--accent-primary);
    color: var(--button-text);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.nav-login-btn:hover {
    background-color: var(--accent-secondary);
    color: var(--button-text);
}

/* ==================== Accent Color Utilities ==================== */
.text-accent {
    color: var(--accent-primary);
}

.bg-accent {
    background-color: var(--accent-primary);
}

.bg-accent-light {
    background-color: var(--accent-light);
}

.border-accent {
    border-color: var(--accent-primary);
}

.hover\:text-accent:hover {
    color: var(--accent-primary);
}

.hover\:bg-accent-light:hover {
    background-color: var(--accent-light);
}

/* Focus ring using accent color */
.focus-accent:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent-light), 0 0 0 4px var(--accent-primary);
}
