/* Existing styles... */

/* ... (keep existing css) ... */
/* FIX: Ensure logo and margin are visible */
#drag_logo {
    z-index: 5;
    /* Ensure it has a size even if image fails or before JS sets it */
    min-width: 50px;
    min-height: 50px;
    display: block;
    /* Force block */
}

#drag_margin.vertical-text {
    z-index: 6;
    /* Ensure visible color against white */
    color: blue;
    /* fallback */
    width: auto;
    height: auto;
    /* Ensure rotation origin is correct */
    transform-origin: top left;
    /* Changed from bottom left to match JS logic better or stick to one */
}

/* ... rest of style.css content if I needed to overwrite it all I would, but I will just append specific fixes via replacement or rewrite? 
   Actually, the user said "Logo no se ve". 
   Let's check if opacity is working.
*/

:root {
    --primary: #2563EB;
    /* Modern Blue */
    --primary-dark: #1E40AF;
    --bg: #F3F4F6;
    --sidebar-bg: #F8FAFC;
    /* Lighter gray/white */
    --text: #1E293B;
    --border: #E2E8F0;
    --surface: #FFFFFF;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    margin: 0;
    background-color: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
}

.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.02);
    z-index: 10;
}

.brand h2 {
    color: var(--primary);
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.config-section {
    background: var(--surface);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.config-section h3 {
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748B;
    font-weight: 600;
}

.config-section label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    margin-bottom: 12px;
    color: var(--text);
}

.config-section label span {
    font-family: monospace;
    font-size: 0.8em;
    background: #F1F5F9;
    padding: 2px 6px;
    border-radius: 4px;
    color: #64748B;
}

/* Custom Range Slider */
input[type="range"] {
    -webkit-appearance: none;
    width: 120px;
    height: 6px;
    background: #E2E8F0;
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

/* Custom Color Input */
input[type="color"] {
    -webkit-appearance: none;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    padding: 0;
    background: none;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 8px;
    border: 1px solid var(--border);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
}

.header {
    display: flex;
    align-items: center;
    margin-bottom: 40px;
    gap: 24px;
}

.header-logo {
    height: 64px;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

.header h1 {
    margin: 0;
    font-size: 1.875rem;
    font-weight: 700;
    color: #0F172A;
    letter-spacing: -0.025em;
}

.header h3 {
    margin: 4px 0 0;
    color: #64748B;
    font-weight: 400;
    font-size: 1rem;
}

.card {
    background: var(--surface);
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    margin-bottom: 32px;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* Forms */
.file-groups {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.file-input label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.9em;
    color: #475569;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    width: 100%;
    transition: all 0.2s;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(37, 99, 235, 0.3);
}

.hidden {
    display: none;
}

/* Table */
.table-container {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    margin: 24px 0;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th {
    background: #F8FAFC;
    padding: 16px;
    text-align: left;
    font-weight: 600;
    color: #475569;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 5;
}

td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    color: #334155;
}

.score-badge {
    padding: 6px 12px;
    border-radius: 9999px;
    color: white;
    font-weight: 600;
    font-size: 0.75rem;
}

.score-high {
    background: #10B981;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(0.98);
        opacity: 0.8;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.pulse-animation {
    animation: pulse 1.5s infinite;
    background-color: #f59e0b !important;
    /* Amber */
    border-color: #f59e0b !important;
    cursor: wait;
}

.score-med {
    background: #F59E0B;
}

.score-low {
    background: #EF4444;
}

input[type="text"] {
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 6px;
    width: 100%;
    box-sizing: border-box;
    font-size: 0.9em;
    transition: border-color 0.2s;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Preview & Generate */
.workspace {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
}

.preview-panel {
    display: flex;
    flex-direction: column;
    /* Allow stacking of title and container */
    justify-content: center;
    align-items: center;
    background: #e2e8f0;
    /* Backdrop for contrast */
    padding: 40px;
    min-width: 400px;
    min-height: 280px;
    position: relative;
}

/* Interactive Preview Styles replace old img style */
.preview-container {
    position: relative;
    width: 480px;
    /* Fixed width for preview, height calc by aspect ratio */
    height: 302px;
    /* 480 / 1.585 approx */
    background-color: white;
    border: 1px solid #ccc;
    overflow: hidden;
    margin: 0 auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    user-select: none;
    /* Prevent text selection while dragging */
    border-radius: 10px;
}

/* Background layer */
.carnet-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background: transparent;
    /* Or a background image if needed */
}

/* Draggable Elements Common */
.draggable-element {
    position: absolute;
    cursor: grab;
    z-index: 10;
    transform-origin: top left;
    border: 1px dashed transparent;
    /* visual cue hover */
    display: inline-block;
    /* shrink to fit content */
}

.draggable-element:hover {
    border: 1px dashed #007bff;
}

.draggable-element:active {
    cursor: grabbing;
    background-color: rgba(0, 123, 255, 0.1);
}

/* Specific Styles */
#drag_logo img {
    /* controlled primarily by JS scaling, but here defaults */
    display: block;
    user-drag: none;
    -webkit-user-drag: none;
    width: 100%;
}

#drag_photo img {
    /* controlled by JS scaling */
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    -webkit-user-drag: none;
    /* Border controlled by JS color */
    box-sizing: border-box;
    border: 3px solid;
    /* color set in JS */
}

#drag_margin.vertical-text {
    /* Vertical text handling */
    white-space: nowrap;
    transform-origin: bottom left;
    /* Rotate around bottom left usually to go up */
    /* Rotation handled in JS */
    color: #0066CC;
    /* Default visible color */
    font-weight: bold;
    /* If rotated -90deg, width becomes height */
}

.text-element {
    white-space: nowrap;
    text-align: center;
    /* font-family set in JS or inherited */
    font-weight: bold;
}

/* z-indices */
#drag_logo {
    z-index: 5;
}

#drag_margin {
    z-index: 50;
}

#drag_photo {
    z-index: 7;
}

#drag_name {
    z-index: 10;
}

#drag_course {
    z-index: 10;
}

#drag_group {
    z-index: 10;
}

/* BORDES TEXTO PREVIEW */
.border-text {
    position: absolute;
    font-size: 8px;
    /* Pequeño para preview */
    color: #0066CC;
    /* Default, overridden by JS */
    white-space: nowrap;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    /* Start from left/top */
    text-transform: uppercase;
    pointer-events: none;
    /* No interactuable */
    z-index: 5;
    background: transparent;
    line-height: 1;
}

.border-top {
    top: 0;
    left: 0;
    width: 100%;
    height: 12px;
    padding-left: 5px;
}

.border-bottom {
    bottom: 0;
    left: 0;
    width: 100%;
    height: 12px;
    padding-left: 5px;
    align-items: flex-end;
}

.border-left {
    top: 0;
    left: 0;
    width: 12px;
    height: 100%;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    /* Para que el texto vaya de abajo arriba */
    padding-bottom: 5px;
    /* Al rotar, start es bottom */
}

.border-right {
    top: 0;
    right: 0;
    width: 12px;
    height: 100%;
    writing-mode: vertical-rl;
    padding-top: 5px;
}

/* TOOLBAR & TABLE FEATURES */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 12px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    align-items: center;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-group {
    flex: 1;
    min-width: 200px;
}

.bulk-group {
    display: flex;
    gap: 12px;
    background: #fff;
    padding: 6px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}

.group-label {
    font-size: 0.85em;
    font-weight: 600;
    color: #64748b;
    align-self: center;
}

.bulk-inputs {
    display: flex;
    gap: 4px;
}

.form-control.small {
    padding: 4px 8px;
    font-size: 0.9em;
    width: 120px;
}

.btn-mini {
    padding: 4px 8px;
    font-size: 0.85em;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.btn-mini:hover {
    background: #2563eb;
}

.toolbar-bottom {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f1f5f9;
    font-size: 0.9em;
}

.btn-link {
    background: none;
    border: none;
    color: #3b82f6;
    cursor: pointer;
    text-decoration: underline;
    font-size: 0.9em;
}

.pagination-controls {
    display: flex;
    gap: 5px;
}

.page-btn {
    padding: 2px 8px;
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 3px;
    cursor: pointer;
    min-width: 24px;
    text-align: center;
}

.page-btn.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.footer-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-top: 1px solid #e2e8f0;
}

/* Progress Bar */
.progress-wrapper {
    margin-top: 15px;
    padding: 10px;
    background: #f8fafc;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.progress-container {
    width: 100%;
    height: 10px;
    background: #e2e8f0;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 5px;
}

.progress-fill {
    height: 100%;
    background: #3b82f6;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.9em;
    color: #64748b;
    text-align: center;
}

/* Table Input Sizing */
#resultsTable input[type="text"] {
    width: 100%;
    /* Fill cell */
    min-width: 80px;
}

.btn-success {
    background: #10B981;
    /* ... rest of existing ... */
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 1.1em;
    transition: all 0.2s;
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.2);
}

.btn-success:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(16, 185, 129, 0.3);
}