/* static/style.css */
/* Laudamed Doc Translator - Shadcn/UI Style */

@import url("https://fonts.googleapis.com/css2?family=Sora:wght@400;600;700&family=Source+Sans+3:wght@400;500;600&display=swap");

/* ============================================
   DESIGN TOKENS (Shadcn/UI compatible)
   ============================================ */

:root {
    /* Base colors (HSL format) */
    --background: 0 0% 100%;
    --foreground: 222 47% 11%;

    /* Cards */
    --card: 0 0% 100%;
    --card-foreground: 222 47% 11%;

    /* Primary - Laudamed brand #18274a = HSL(220, 51%, 19%) */
    --primary: 220 51% 19%;
    --primary-foreground: 0 0% 98%;

    /* Secondary */
    --secondary: 220 14% 96%;
    --secondary-foreground: 220 51% 19%;

    /* Muted */
    --muted: 220 14% 96%;
    --muted-foreground: 220 9% 46%;

    /* Accent */
    --accent: 220 14% 96%;
    --accent-foreground: 220 51% 19%;

    /* Destructive */
    --destructive: 0 84% 60%;
    --destructive-foreground: 0 0% 98%;

    /* Success */
    --success: 142 76% 36%;
    --success-foreground: 0 0% 98%;

    /* Warning */
    --warning: 38 92% 50%;
    --warning-foreground: 0 0% 98%;

    /* Border, Input, Ring */
    --border: 220 13% 91%;
    --input: 220 13% 91%;
    --ring: 220 51% 19%;

    /* Radius */
    --radius: 0.5rem;
}

/* ============================================
   BASE STYLES
   ============================================ */

body {
    font-family: "Source Sans 3", "Sora", sans-serif;
    background-color: hsl(var(--muted));
    color: hsl(var(--foreground));
}

h1, h2, h3 {
    font-family: "Sora", sans-serif;
}

/* Page container */
.page-shell {
    max-width: 1024px;
}

/* Logo */
.logo {
    max-width: 140px;
    height: auto;
    object-fit: contain;
}

/* Form controls accent */
input[type="checkbox"],
input[type="radio"] {
    accent-color: hsl(var(--primary));
}

/* Loading spinner */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* ============================================
   ADVANCED OPTIONS (index.html specific)
   ============================================ */

.advanced-section {
    background-color: hsl(var(--muted));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 1rem;
}

.advanced-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: hsl(var(--muted-foreground));
    margin-bottom: 0.75rem;
}

/* Patch option - checkbox with description */
.patch-option {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.patch-option:hover {
    background-color: hsl(var(--primary) / 0.04);
}

.patch-option input[type="checkbox"] {
    margin-top: 2px;
    flex-shrink: 0;
}

.patch-option div {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.patch-name {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.8rem;
    font-weight: 500;
    color: hsl(var(--primary));
}

.patch-desc {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    line-height: 1.3;
}

/* ============================================
   SHADCN/UI COMPONENT CLASSES
   ============================================ */

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
    cursor: pointer;
    border: none;
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring));
}

.btn:disabled {
    pointer-events: none;
    opacity: 0.5;
}

.btn-primary {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    height: 2.5rem;
    padding: 0 1rem;
}

.btn-primary:hover {
    background-color: hsl(var(--primary) / 0.9);
}

.btn-secondary {
    background-color: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
    height: 2.5rem;
    padding: 0 1rem;
}

.btn-secondary:hover {
    background-color: hsl(var(--secondary) / 0.8);
}

.btn-ghost {
    background-color: transparent;
    height: 2.5rem;
    padding: 0 1rem;
}

.btn-ghost:hover {
    background-color: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
}

.btn-destructive {
    background-color: hsl(var(--destructive));
    color: hsl(var(--destructive-foreground));
    height: 2.5rem;
    padding: 0 1rem;
}

.btn-destructive:hover {
    background-color: hsl(var(--destructive) / 0.9);
}

.btn-outline {
    border: 1px solid hsl(var(--input));
    background-color: hsl(var(--background));
    height: 2.5rem;
    padding: 0 1rem;
}

.btn-outline:hover {
    background-color: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
}

.btn-link {
    color: hsl(var(--primary));
    text-decoration-line: underline;
    text-underline-offset: 4px;
    background: transparent;
    height: auto;
    padding: 0;
}

.btn-link:hover {
    text-decoration-line: underline;
}

.btn-sm {
    height: 2.25rem;
    padding: 0 0.75rem;
    font-size: 0.8125rem;
}

.btn-lg {
    height: 2.75rem;
    padding: 0 2rem;
    font-size: 1rem;
}

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

/* === INPUTS === */
.input {
    display: flex;
    height: 2.5rem;
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid hsl(var(--input));
    background-color: hsl(var(--background));
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input::placeholder {
    color: hsl(var(--muted-foreground));
}

.input:focus {
    outline: none;
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring) / 0.3);
}

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

.select {
    display: flex;
    height: 2.5rem;
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid hsl(var(--input));
    background-color: hsl(var(--background));
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.select:focus {
    outline: none;
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring) / 0.3);
}

/* === BADGES === */
.badge {
    display: inline-flex;
    align-items: center;
    border-radius: calc(var(--radius) - 2px);
    padding: 0.125rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-default {
    background-color: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
}

.badge-primary {
    background-color: hsl(var(--primary) / 0.1);
    color: hsl(var(--primary));
}

.badge-success {
    background-color: hsl(var(--success) / 0.1);
    color: hsl(var(--success));
}

.badge-destructive {
    background-color: hsl(var(--destructive) / 0.1);
    color: hsl(var(--destructive));
}

.badge-warning {
    background-color: hsl(var(--warning) / 0.1);
    color: hsl(var(--warning));
}

.badge-outline {
    border: 1px solid hsl(var(--border));
    background-color: transparent;
}

/* === CARDS === */
.card-shadcn {
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
    background-color: hsl(var(--card));
    color: hsl(var(--card-foreground));
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.card-header-shadcn {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    padding: 1.5rem;
}

.card-title-shadcn {
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1;
    letter-spacing: -0.025em;
}

.card-description {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
}

.card-content-shadcn {
    padding: 1.5rem;
    padding-top: 0;
}

.card-footer {
    display: flex;
    align-items: center;
    padding: 1.5rem;
    padding-top: 0;
}

/* === PROGRESS BAR === */
.progress-shadcn {
    position: relative;
    height: 0.5rem;
    width: 100%;
    overflow: hidden;
    border-radius: 9999px;
    background-color: hsl(var(--secondary));
}

.progress-bar-shadcn {
    height: 100%;
    background-color: hsl(var(--primary));
    transition: width 0.3s ease;
}

/* === DIALOG/MODAL === */
.dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgb(0 0 0 / 0.8);
    backdrop-filter: blur(4px);
}

.dialog {
    position: fixed;
    left: 50%;
    top: 50%;
    z-index: 50;
    display: grid;
    width: 100%;
    max-width: 28rem;
    transform: translate(-50%, -50%);
    gap: 1rem;
    border: 1px solid hsl(var(--border));
    background-color: hsl(var(--background));
    padding: 1.5rem;
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
    border-radius: var(--radius);
}

.dialog-header {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    text-align: center;
}

@media (min-width: 640px) {
    .dialog-header {
        text-align: left;
    }
}

.dialog-title {
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1;
    letter-spacing: -0.025em;
}

.dialog-description {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
}

.dialog-footer {
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
}

@media (min-width: 640px) {
    .dialog-footer {
        flex-direction: row;
        justify-content: flex-end;
    }
}

/* === ALERTS === */
.alert {
    position: relative;
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
    padding: 1rem;
}

.alert-success {
    border-color: hsl(var(--success) / 0.5);
    background-color: hsl(var(--success) / 0.1);
    color: hsl(var(--success));
}

.alert-destructive {
    border-color: hsl(var(--destructive) / 0.5);
    background-color: hsl(var(--destructive) / 0.1);
    color: hsl(var(--destructive));
}

.alert-warning {
    border-color: hsl(var(--warning) / 0.5);
    background-color: hsl(var(--warning) / 0.1);
    color: hsl(var(--warning));
}

/* === LABEL === */
.label {
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1;
}

/* === SEPARATOR === */
.separator {
    flex-shrink: 0;
    background-color: hsl(var(--border));
}

.separator-horizontal {
    height: 1px;
    width: 100%;
}

.separator-vertical {
    height: 100%;
    width: 1px;
}

/* === SWITCH/TOGGLE === */
.switch {
    position: relative;
    display: inline-flex;
    cursor: pointer;
    align-items: center;
}

.switch input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.switch-track {
    height: 1.5rem;
    width: 2.75rem;
    border-radius: 9999px;
    background-color: hsl(var(--input));
    transition: background-color 0.15s ease;
}

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

.switch-thumb {
    position: absolute;
    left: 2px;
    top: 2px;
    height: 1.25rem;
    width: 1.25rem;
    border-radius: 9999px;
    background-color: hsl(var(--background));
    transition: transform 0.15s ease;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.switch input:checked ~ .switch-thumb {
    transform: translateX(1.25rem);
}

.switch input:focus-visible + .switch-track {
    box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring));
}

/* === TABLE === */
.table-shadcn {
    width: 100%;
    caption-side: bottom;
    font-size: 0.875rem;
}

.table-shadcn thead tr {
    border-bottom: 1px solid hsl(var(--border));
}

.table-shadcn th {
    height: 3rem;
    padding: 0 1rem;
    text-align: left;
    vertical-align: middle;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
}

.table-shadcn tbody tr {
    border-bottom: 1px solid hsl(var(--border));
    transition: background-color 0.15s ease;
}

.table-shadcn tbody tr:last-child {
    border-bottom: none;
}

.table-shadcn tbody tr:hover {
    background-color: hsl(var(--muted) / 0.5);
}

.table-shadcn td {
    padding: 1rem;
    vertical-align: middle;
}

/* === DROP ZONE === */
.drop-zone-shadcn {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    border: 2px dashed hsl(var(--muted-foreground) / 0.25);
    background-color: hsl(var(--muted) / 0.5);
    padding: 2rem;
    text-align: center;
    transition: border-color 0.15s ease, background-color 0.15s ease;
    cursor: pointer;
}

.drop-zone-shadcn:hover {
    border-color: hsl(var(--muted-foreground) / 0.5);
    background-color: hsl(var(--muted));
}

.drop-zone-shadcn.active {
    border-color: hsl(var(--primary));
    background-color: hsl(var(--primary) / 0.05);
}

/* === COLLAPSIBLE === */
.collapsible {
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
}

.collapsible summary {
    display: flex;
    cursor: pointer;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.15s ease;
    list-style: none;
}

.collapsible summary::-webkit-details-marker {
    display: none;
}

.collapsible summary::before {
    display: none;
}

.collapsible summary:hover {
    background-color: hsl(var(--muted) / 0.5);
}

.collapsible[open] summary {
    border-bottom: 1px solid hsl(var(--border));
}

.collapsible-content {
    padding: 1rem;
}

.collapsible-icon {
    height: 1rem;
    width: 1rem;
    transition: transform 0.2s ease;
}

.collapsible[open] .collapsible-icon {
    transform: rotate(180deg);
}

/* ============================================
   PDF EDITOR
   ============================================ */

.pdf-canvas {
    display: block;
}

.pdf-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

#pdf-text-layer {
    pointer-events: auto;
    z-index: 20;
}

#pdf-mask-layer {
    z-index: 10;
}

.pdf-element {
    position: absolute;
    box-sizing: border-box;
    border: 1px solid transparent;
    background-color: transparent;
    cursor: pointer;
    pointer-events: auto;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.pdf-element-content {
    width: 100%;
    height: 100%;
    line-height: 1.2;
    white-space: pre-wrap;
    overflow: hidden;
    outline: none;
}

.pdf-element-text:hover {
    border-color: hsl(var(--primary) / 0.4);
    background-color: hsl(var(--primary) / 0.05);
}

.pdf-element-image:hover {
    border-color: hsl(var(--success) / 0.5);
    background-color: hsl(var(--success) / 0.08);
}

.pdf-element-drawing:hover {
    border-color: hsl(var(--ring) / 0.5);
    background-color: hsl(var(--ring) / 0.08);
}

.pdf-element.is-selected {
    border-color: hsl(var(--primary));
    box-shadow: 0 0 0 2px hsl(var(--primary) / 0.2);
    background-color: hsl(var(--primary) / 0.08);
}

.pdf-element.is-modified {
    border-color: hsl(var(--warning));
    box-shadow: 0 0 0 2px hsl(var(--warning) / 0.2);
    background-color: hsl(var(--warning) / 0.12);
}

.pdf-element.is-editing {
    border-color: hsl(var(--primary));
    background-color: hsl(var(--background) / 0.9);
}

.pdf-element.is-moving {
    border-color: hsl(var(--warning));
    background-color: hsl(var(--background) / 0.9);
}

.pdf-element-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background-color: hsl(var(--background));
    border: 1px solid hsl(var(--primary));
    border-radius: 2px;
    display: none;
}

.pdf-element.is-selected .pdf-element-handle,
.pdf-element.is-editing .pdf-element-handle {
    display: block;
}

.handle-nw { top: -5px; left: -5px; cursor: nwse-resize; }
.handle-ne { top: -5px; right: -5px; cursor: nesw-resize; }
.handle-sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.handle-se { bottom: -5px; right: -5px; cursor: nwse-resize; }

.pdf-element-mask {
    position: absolute;
    pointer-events: none;
    border-radius: 2px;
}
