/* Reusable Component Styles */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.375rem;
    transition: all 0.2s;
    cursor: pointer;
    outline: none;
    border: 1px solid transparent;
    gap: 0.5rem;
}

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

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

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

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

.btn-secondary:hover:not(:disabled) {
    background: var(--border-color);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.btn-success {
    background: var(--secondary-color);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #059669;
}

.btn-ghost {
    background: transparent;
    color: var(--text-primary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-secondary);
}

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn-icon {
    padding: 0.5rem;
    width: 2.5rem;
    height: 2.5rem;
}

.btn-rounded {
    border-radius: 9999px;
}

/* Input Groups */
.input-group {
    position: relative;
    margin-bottom: 1rem;
}

.input-label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.input-field {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.1);
}

.input-field:disabled {
    background: var(--bg-secondary);
    cursor: not-allowed;
    opacity: 0.6;
}

.input-error {
    border-color: var(--danger-color);
}

.input-error:focus {
    box-shadow: 0 0 0 3px rgba(127, 29, 29, 0.1);
}

.input-helper {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.input-error-message {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--danger-color);
}

/* Select Dropdown */
.select-wrapper {
    position: relative;
}

.select-field {
    appearance: none;
    width: 100%;
    padding: 0.5rem 2.5rem 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

.select-field:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.1);
}

.select-icon {
    position: absolute;
    top: 50%;
    right: 0.75rem;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-secondary);
}

/* Checkbox & Radio */
.checkbox-wrapper,
.radio-wrapper {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
}

.checkbox-input,
.radio-input {
    width: 1rem;
    height: 1rem;
    margin-right: 0.5rem;
    cursor: pointer;
}

.checkbox-label,
.radio-label {
    font-size: 0.875rem;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
}

/* Switch Toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

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

.switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--text-secondary);
    transition: 0.3s;
    border-radius: 24px;
}

.switch-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background: white;
    transition: 0.3s;
    border-radius: 50%;
}

.switch input:checked + .switch-slider {
    background: var(--primary-color);
}

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

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

.tab {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

.tab-content {
    padding: 1rem 0;
}

.tab-panel {
    display: none;
}

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

/* Dropdown Menu - Moved to main.css to avoid conflicts */
/* Dropdown styles are now managed in main.css with the .show class */

/* Progress Bar */
.progress {
    width: 100%;
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-hover));
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Avatar */
.avatar {
    display: inline-block;
    position: relative;
    border-radius: 50%;
    overflow: hidden;
}

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

.avatar-xs {
    width: 24px;
    height: 24px;
}

.avatar-sm {
    width: 32px;
    height: 32px;
}

.avatar-md {
    width: 40px;
    height: 40px;
}

.avatar-lg {
    width: 48px;
    height: 48px;
}

.avatar-xl {
    width: 64px;
    height: 64px;
}

.avatar-status {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 25%;
    height: 25%;
    border: 2px solid var(--bg-primary);
    border-radius: 50%;
}

.avatar-status.online {
    background: #22c55e;
}

.avatar-status.offline {
    background: #6b7280;
}

.avatar-status.busy {
    background: #ef4444;
}

.avatar-status.away {
    background: #f59e0b;
}

/* Chips/Tags */
.chip {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 9999px;
    gap: 0.25rem;
}

.chip-primary {
    background: rgba(100, 116, 139, 0.1);
    color: var(--primary-color);
}

.chip-success {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.chip-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.chip-removable {
    padding-right: 0.25rem;
}

.chip-remove {
    margin-left: 0.25rem;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.chip-remove:hover {
    opacity: 1;
}

/* List Group */
.list-group {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    overflow: hidden;
}

.list-group-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    transition: background 0.2s;
}

.list-group-item:last-child {
    border-bottom: none;
}

.list-group-item:hover {
    background: var(--bg-secondary);
}

.list-group-item.active {
    background: var(--primary-color);
    color: white;
}

/* Pagination */
.pagination {
    display: flex;
    gap: 0.25rem;
}

.page-link {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
}

.page-link:hover {
    background: var(--bg-secondary);
}

.page-link.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.page-link:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    font-size: 0.875rem;
}

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

.breadcrumb-item + .breadcrumb-item::before {
    content: "/";
    padding: 0 0.5rem;
    color: var(--text-secondary);
}

.breadcrumb-item.active {
    color: var(--text-primary);
    font-weight: 500;
}

.breadcrumb-item a {
    color: var(--primary-color);
    text-decoration: none;
}

.breadcrumb-item a:hover {
    text-decoration: underline;
}

/* Accordion */
.accordion {
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    overflow: hidden;
}

.accordion-item {
    border-bottom: 1px solid var(--border-color);
}

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

.accordion-header {
    padding: 1rem;
    background: var(--bg-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s;
}

.accordion-header:hover {
    background: var(--bg-secondary);
}

.accordion-header.active {
    background: var(--bg-secondary);
}

.accordion-icon {
    transition: transform 0.2s;
}

.accordion-header.active .accordion-icon {
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.accordion-content.show {
    max-height: 500px;
}

.accordion-body {
    padding: 1rem;
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    transition: all 0.3s;
    z-index: 50;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.fab:active {
    transform: scale(0.95);
}

/* Stepper */
.stepper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.step:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 20px;
    left: 50%;
    width: 100%;
    height: 2px;
    background: var(--border-color);
    z-index: -1;
}

.step.completed:not(:last-child)::after {
    background: var(--primary-color);
}

.step-indicator {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.step.active .step-indicator {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.step.completed .step-indicator {
    background: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
}

.step-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
}

.step.active .step-label,
.step.completed .step-label {
    color: var(--text-primary);
    font-weight: 500;
}

/* Code Block Styles - Modern with light-dark() support */
:root {
    color-scheme: light dark;
    
    /* Code block color variables */
    --code-bg: light-dark(#f6f8fa, #0d1117);
    --code-header-bg: light-dark(#f0f3f6, #161b22);
    --code-border: light-dark(#d1d5db, #30363d);
    --code-text: light-dark(#24292e, #e6edf3);
    --code-lang: light-dark(#586069, #8b949e);
    --code-copy-bg: light-dark(#ffffff, #21262d);
    --code-copy-hover: light-dark(#f3f4f6, #30363d);
    --code-copy-success: #10b981;
    --inline-code-bg: light-dark(rgba(175, 184, 193, 0.2), rgba(110, 118, 129, 0.4));
    --inline-code-text: light-dark(#0969da, #79c0ff);
}

/* Code Block Container */
.code-block-container {
    margin: 1rem 0;
    border-radius: 0.5rem;
    overflow: hidden;
    border: 1px solid var(--code-border);
    background: var(--code-bg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
}

/* Code Block Header */
.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: var(--code-header-bg);
    border-bottom: 1px solid var(--code-border);
}

.code-block-lang {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--code-lang);
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
    text-transform: lowercase;
}

/* Copy Button */
.code-block-copy {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--code-lang);
    background: var(--code-copy-bg);
    border: 1px solid var(--code-border);
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: system-ui, -apple-system, sans-serif;
}

.code-block-copy:hover {
    background: var(--code-copy-hover);
    transform: translateY(-1px);
}

.code-block-copy.copied {
    background: var(--code-copy-success) !important;
    color: white !important;
    border-color: var(--code-copy-success) !important;
}

.code-block-copy i {
    font-size: 0.75rem;
}

.code-block-copy .copy-text {
    display: inline-block;
}

/* Code Block Pre and Code Elements */
.code-block-pre {
    margin: 0 !important;
    padding: 1rem !important;
    overflow-x: auto !important;
    background: var(--code-bg) !important;
    border: none !important;
    border-radius: 0 !important;
    
    /* Critical: Preserve whitespace and formatting */
    white-space: pre !important;
    word-wrap: normal !important;
    word-break: normal !important;
    line-break: auto !important;
}

.code-block-pre code {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    
    /* Font settings */
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace !important;
    font-size: 0.875rem !important;
    line-height: 1.45 !important;
    
    /* Color */
    color: var(--code-text) !important;
    background: transparent !important;
    
    /* Critical: Preserve whitespace */
    white-space: pre !important;
    word-wrap: normal !important;
    tab-size: 4 !important;
}

/* Scrollbar styling for code blocks */
.code-block-pre::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

.code-block-pre::-webkit-scrollbar-track {
    background: var(--code-header-bg);
}

.code-block-pre::-webkit-scrollbar-thumb {
    background: var(--code-border);
    border-radius: 4px;
}

.code-block-pre::-webkit-scrollbar-thumb:hover {
    background: var(--code-lang);
}

/* Inline code styles */
code.inline-code {
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.85em;
    background: var(--inline-code-bg);
    color: var(--inline-code-text);
    word-break: break-word;
}

/* Prism.js token colors override for consistency */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
    color: light-dark(#6a737d, #8b949e);
}

.token.punctuation {
    color: light-dark(#24292e, #c9d1d9);
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
    color: light-dark(#0969da, #79c0ff);
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
    color: light-dark(#032f62, #a5d6ff);
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
    color: light-dark(#d73a49, #ff7b72);
}

.token.atrule,
.token.attr-value,
.token.keyword {
    color: light-dark(#d73a49, #ff7b72);
}

.token.function,
.token.class-name {
    color: light-dark(#6f42c1, #d2a8ff);
}

.token.regex,
.token.important,
.token.variable {
    color: light-dark(#e36209, #ffa657);
}