* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-color: #0f172a;
    --panel-bg: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --accent-primary: #3b82f6;
    --accent-hover: #2563eb;
    --accent-secondary: #475569;
    --accent-secondary-hover: #334155;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --item-bg: rgba(255, 255, 255, 0.02);
    --th-bg: rgba(255, 255, 255, 0.03);
    --cell-border: rgba(255, 255, 255, 0.05);
    --table-hover: rgba(255, 255, 255, 0.05);
    --error-bg: rgba(239, 68, 68, 0.1);
    --error-border: rgba(239, 68, 68, 0.3);
    --error-text: #fca5a5;
    --success-bg: rgba(34, 197, 94, 0.1);
    --success-text: #86efac;
}

[data-theme="light"] {
    --bg-color: #f8fafc;
    --panel-bg: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --accent-primary: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-secondary: #e2e8f0;
    --accent-secondary-hover: #cbd5e1;
    --border-color: rgba(0, 0, 0, 0.1);
    --item-bg: rgba(0, 0, 0, 0.02);
    --th-bg: rgba(0, 0, 0, 0.03);
    --cell-border: rgba(0, 0, 0, 0.1);
    --table-hover: rgba(0, 0, 0, 0.05);
    --error-bg: rgba(239, 68, 68, 0.1);
    --error-border: rgba(239, 68, 68, 0.3);
    --error-text: #dc2626;
    --success-bg: rgba(34, 197, 94, 0.1);
    --success-text: #16a34a;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-color);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-primary);
    transition: background 0.3s ease, color 0.3s ease;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    background: transparent;
    color: var(--text-primary);
    padding: 20px 0;
    text-align: center;
    position: relative;
    margin-bottom: 12px;
}

header h1 {
    font-size: 1.75rem;
    margin: 0;
    font-weight: 600;
    letter-spacing: -0.025em;
}

.header-controls {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}


.theme-selector,
.language-selector {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    outline: none;
}

.theme-selector:hover,
.language-selector:hover {
    background: var(--item-bg);
    border-color: var(--accent-primary);
}

.theme-selector:focus,
.language-selector:focus {
    border-color: var(--accent-primary);
    background: var(--item-bg);
}

.theme-selector option,
.language-selector option {
    background: var(--panel-bg);
    color: var(--text-primary);
}

main {
    max-width: 1400px;
    margin: 0 auto;
}

.input-section {
    background: var(--panel-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

.input-section label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-primary);
    font-size: 1rem;
}

.format-selector-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.format-selector-container label {
    margin-bottom: 0;
    font-size: 1em;
}

.format-selector {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--panel-bg);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    outline: none;
}

.format-selector:hover {
    background: var(--item-bg);
}

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

/* Editor bottom controls container */
.editor-bottom-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    gap: 16px;
}

/* Font control styles */
.font-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--item-bg);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    width: fit-content;
}

.font-btn {
    background: var(--accent-secondary);
    border: none;
    border-radius: var(--radius-md);
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.font-btn:hover {
    background: var(--accent-secondary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.font-btn:active {
    transform: translateY(0);
}

#font-size-display {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
    min-width: 40px;
    text-align: center;
    font-weight: 600;
}

/* Prism code editor with line numbers */
#rdf-code-pre {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin: 0 !important;
    font-size: 14px;
    max-height: 500px;
    overflow: auto;
    background: var(--item-bg);
    transition: border-color 0.3s, background 0.3s;
}

#rdf-code-pre:focus-within {
    border-color: var(--accent-primary);
    outline: none;
}

#rdf-input {
    outline: none;
    min-height: 300px;
    display: block;
    width: 100%;
}

#rdf-input:focus {
    outline: none;
}

/* Prism line numbers styling */
pre.line-numbers {
    position: relative;
    padding-left: 3.8em;
    counter-reset: linenumber;
}

pre.line-numbers > code {
    position: relative;
    white-space: pre;
}

.line-numbers .line-numbers-rows {
    position: absolute;
    pointer-events: none;
    top: 0;
    font-size: 100%;
    left: -3.8em;
    width: 3em;
    letter-spacing: -1px;
    border-right: 1px solid var(--border-color);
    user-select: none;
}

.line-numbers-rows > span {
    display: block;
    counter-increment: linenumber;
}

.line-numbers-rows > span:before {
    content: counter(linenumber);
    color: var(--text-muted);
    display: block;
    padding-right: 0.8em;
    text-align: right;
}

.verify-button {
    padding: 10px 20px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.verify-button:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.verify-button:active {
    transform: translateY(0);
}

.error-message {
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 20px;
    color: var(--error-text);
    font-weight: 500;
    font-size: 0.9rem;
}

.error-message.hidden {
    display: none;
}

.results-section {
    background: var(--panel-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

.results-section.hidden {
    display: none;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.results-header h2 {
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 700;
}

.status-badge {
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.85rem;
}

.status-badge.success {
    background: var(--success-bg);
    color: var(--success-text);
}

.results-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.triples-section,
.graph-section {
    background: var(--item-bg);
    padding: 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.triples-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.triples-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
}

.graph-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.graph-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
}

.graph-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9em;
    color: var(--text-secondary);
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

.checkbox-label span {
    white-space: nowrap;
}

.fullscreen-button {
    background: var(--accent-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 6px 12px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    display: flex !important;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    position: relative;
    z-index: 10;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.fullscreen-button:hover {
    background: var(--accent-secondary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.fullscreen-button:active {
    transform: translateY(0);
}

.fullscreen-icon {
    display: inline-block;
    font-size: 20px;
    line-height: 1;
}

/* Estilos para pantalla completa */
.graph-section.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    background: var(--bg-color);
    padding: 20px;
    border-radius: 0;
    margin: 0;
}

.graph-section.fullscreen #graph-container {
    height: calc(100vh - 100px);
    width: 100%;
}

/* Asegurar que el botón siempre sea visible */
.graph-section.fullscreen .fullscreen-button {
    z-index: 10000;
    position: relative;
}

/* Resetear estilos cuando no está en pantalla completa */
.graph-section:not(.fullscreen) {
    position: relative;
    width: auto;
    height: auto;
    padding: 20px;
    border-radius: var(--radius-md);
    margin: 0;
    background: var(--item-bg);
    z-index: auto;
    top: auto;
    left: auto;
}

.graph-section:not(.fullscreen) #graph-container {
    width: 100%;
    height: 500px;
    max-width: none;
    max-height: none;
}

/* Estilos para pantalla completa de tripletas */
.triples-section.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    background: var(--bg-color);
    padding: 20px;
    border-radius: 0;
    margin: 0;
}

.triples-section.fullscreen .table-container {
    max-height: calc(100vh - 100px);
    height: calc(100vh - 100px);
}

/* Asegurar que el botón siempre sea visible en tripletas fullscreen */
.triples-section.fullscreen .fullscreen-button {
    z-index: 10000;
    position: relative;
}

/* Resetear estilos cuando no está en pantalla completa */
.triples-section:not(.fullscreen) {
    position: relative;
    width: auto;
    height: auto;
    padding: 20px;
    border-radius: var(--radius-md);
    margin: 0;
    background: var(--item-bg);
    z-index: auto;
    top: auto;
    left: auto;
}

.triples-section:not(.fullscreen) .table-container {
    max-height: 500px;
}


.table-container {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--panel-bg);
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9rem;
}

thead {
    background: var(--th-bg);
    color: var(--text-secondary);
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    word-break: break-word;
    color: var(--text-primary);
}

tbody tr:hover {
    background: var(--table-hover);
}

tbody tr:last-child td {
    border-bottom: none;
}

#graph-container {
    width: 100%;
    height: 500px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--panel-bg);
}

/* Estilos para la sección SPARQL */
.sparql-section {
    background: var(--panel-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

.sparql-section.hidden {
    display: none;
}

.sparql-section h2 {
    color: var(--text-primary);
    font-size: 1.25rem;
    margin-bottom: 8px;
    font-weight: 700;
}

.sparql-description {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.sparql-input-section {
    margin-bottom: 30px;
}

.sparql-input-section label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-primary);
    font-size: 1rem;
}

/* SPARQL font controls */
.sparql-font-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--item-bg);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    width: fit-content;
}

#sparql-font-size-display {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
    min-width: 40px;
    text-align: center;
    font-weight: 600;
}

/* SPARQL code editor with line numbers */
#sparql-code-pre {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin: 0 !important;
    font-size: 14px;
    max-height: 400px;
    overflow: auto;
    background: var(--item-bg);
    transition: border-color 0.3s;
}

#sparql-code-pre:focus-within {
    border-color: var(--accent-primary);
    outline: none;
}

#sparql-input {
    outline: none;
    min-height: 200px;
    display: block;
    width: 100%;
}

#sparql-input:focus {
    outline: none;
}

.execute-button {
    padding: 10px 20px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.execute-button:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.execute-button:active {
    transform: translateY(0);
}

.execute-button:disabled {
    background: var(--accent-secondary);
    cursor: not-allowed;
    transform: none;
    opacity: 0.6;
}

.sparql-results {
    margin-top: 30px;
}

.sparql-results.hidden {
    display: none;
}

.sparql-results h3 {
    margin-bottom: 16px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
}

@media (max-width: 1024px) {
    .results-content {
        grid-template-columns: 1fr;
    }
}

/* Footer */
footer {
    text-align: center;
    padding: 40px 20px;
    margin-top: 40px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
}

footer a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color 0.2s;
}

footer a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: var(--accent-secondary);
    border-radius: 5px;
    border: 2px solid var(--bg-color);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-secondary-hover);
}

/* Prism syntax highlighting - dark theme colors */
:root code[class*="language-"],
:root pre[class*="language-"] {
    color: var(--text-primary);
    text-shadow: none;
}

:root .token.comment,
:root .token.prolog,
:root .token.doctype,
:root .token.cdata {
    color: var(--text-secondary);
}

:root .token.punctuation {
    color: var(--text-primary);
    opacity: 0.7;
}

:root .token.property,
:root .token.tag,
:root .token.boolean,
:root .token.number,
:root .token.constant,
:root .token.symbol,
:root .token.deleted {
    color: #ff9d76;
}

:root .token.selector,
:root .token.attr-name,
:root .token.string,
:root .token.char,
:root .token.builtin,
:root .token.inserted {
    color: #a8e6cf;
}

:root .token.operator,
:root .token.entity,
:root .token.url,
:root .language-css .token.string,
:root .style .token.string {
    color: #ffd89b;
}

:root .token.atrule,
:root .token.attr-value,
:root .token.keyword {
    color: #82c4ff;
}

:root .token.function,
:root .token.class-name {
    color: #ffb3d9;
}

:root .token.regex,
:root .token.important,
:root .token.variable {
    color: #ffa07a;
}

/* Prism syntax highlighting - light theme colors */
[data-theme="light"] code[class*="language-"],
[data-theme="light"] pre[class*="language-"] {
    color: var(--text-primary);
}

[data-theme="light"] .token.comment,
[data-theme="light"] .token.prolog,
[data-theme="light"] .token.doctype,
[data-theme="light"] .token.cdata {
    color: #708090;
}

[data-theme="light"] .token.punctuation {
    color: #999;
}

[data-theme="light"] .token.property,
[data-theme="light"] .token.tag,
[data-theme="light"] .token.boolean,
[data-theme="light"] .token.number,
[data-theme="light"] .token.constant,
[data-theme="light"] .token.symbol,
[data-theme="light"] .token.deleted {
    color: #d73a49;
}

[data-theme="light"] .token.selector,
[data-theme="light"] .token.attr-name,
[data-theme="light"] .token.string,
[data-theme="light"] .token.char,
[data-theme="light"] .token.builtin,
[data-theme="light"] .token.inserted {
    color: #22863a;
}

[data-theme="light"] .token.operator,
[data-theme="light"] .token.entity,
[data-theme="light"] .token.url,
[data-theme="light"] .language-css .token.string,
[data-theme="light"] .style .token.string {
    color: #e36209;
}

[data-theme="light"] .token.atrule,
[data-theme="light"] .token.attr-value,
[data-theme="light"] .token.keyword {
    color: #0366d6;
}

[data-theme="light"] .token.function,
[data-theme="light"] .token.class-name {
    color: #6f42c1;
}

[data-theme="light"] .token.regex,
[data-theme="light"] .token.important,
[data-theme="light"] .token.variable {
    color: #e36209;
}

@media (max-width: 768px) {
    header {
        padding: 16px 0;
    }
    
    header h1 {
        font-size: 1.25rem;
        margin-bottom: 12px;
    }

    main {
        padding: 0;
    }
    
    .input-section,
    .results-section,
    .sparql-section {
        border-radius: var(--radius-md);
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .format-selector-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .editor-bottom-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .font-controls,
    .sparql-font-controls {
        order: -1;
    }
    
    .header-controls {
        position: static;
        transform: none;
        justify-content: center;
        margin-top: 12px;
        flex-wrap: wrap;
    }
    
    .theme-selector,
    .language-selector {
        font-size: 0.8rem;
    }
    
    .results-content {
        grid-template-columns: 1fr;
    }
}
