/* Global Clean Reset */
:root {
    --primary-color: #007bff;
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-main: #1f2937;
    --text-sub: #6b7280;
    --border-color: #e5e7eb;
    --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);
    --radius: 8px;
}

/* Page Container removed (using global .corpo) */

/* Main Content Box defined in styles.css */

/* Controls Bar */
.controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 20px;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.actions-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.page-title {
    font-size: 1.6rem;
    color: var(--text-main);
    margin: 0;
}

.search-container {
    flex-grow: 1;
    max-width: 500px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 20px;
}

.search-container input {
    width: 100%;
    padding: 10px 10px 10px 40px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.95rem;
    background: #fafafa;
    transition: all 0.2s;
}

.search-container input:focus {
    outline: none;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
    border-color: var(--primary-color);
}

.search-icon {
    position: absolute;
    left: 15px;
    color: var(--text-sub);
}

.filter-options {
    display: flex;
    gap: 15px;
    /* Increased gap between groups */
    font-size: 0.85rem;
    color: var(--text-sub);
    white-space: nowrap;
    align-items: center;
}

.filter-options label {
    display: flex;
    /* Flex inside the label to align box and text */
    align-items: center;
    gap: 6px;
    /* Spacing between box and text */
    cursor: pointer;
}

/* Columns / Masonry Layout */
.board-columns-container {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.column-lane {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
    /* Fix flex overflow */
}

/* Category Card */
.category-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Fill grid cell */
    width: 100%;
    /* For header radius */
    transition: box-shadow 0.2s;
}

.category-card:hover {
    box-shadow: var(--shadow-md);
}

.category-header {
    background: #f8fafc;
    padding: 4px 15px;
    border-bottom: 1px solid #edf2f7;
    font-weight: 600;
    color: #2d3748;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
    position: relative;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
}

.collapse-icon {
    cursor: pointer;
    color: #a0aec0;
    transition: transform 0.2s;
    padding: 4px;
}

.collapse-icon:hover {
    color: var(--primary-color);
}

/* Collapsed State */
.category-card.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.category-card.collapsed .category-body,
.category-card.collapsed .category-footer {
    display: none;
}

.cat-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cat-actions {
    display: none;
    /* Changed via JS to flex in Edit Mode */
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    gap: 8px;
    background: inherit;
    /* Blend with header */
}



/* Body */
.category-body {
    padding: 10px;
    background: #fff;
    min-height: 60px;
    /* Increased for better drop target */
    /* Drop target size */
}

.item-card.private {
    border-left-color: #f59e0b;
    /* Orange/Gold for private items */
    background: #fffbef;
}

/* Items */
.item-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-left: 4px solid var(--primary-color);
    padding: 10px 12px;
    padding-right: 50px;
    /* Reserve space for actions always */
    margin-bottom: 8px;
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    transition: transform 0.1s, box-shadow 0.1s;
    display: flex;
    /* Back to Flexbox for vertical centering */
    align-items: center;
    /* Vertical Center */
    min-height: 46px;
    /* Ensure consistent height */
}

.item-card:hover {
    transform: translateX(2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.item-title {
    font-size: 0.95rem;
    color: #4a5568;
    word-break: break-word;
    flex-grow: 1;
}

.item-actions {
    position: absolute;
    right: 8px;
    /* Fixed distance from right */
    top: 50%;
    transform: translateY(-50%);
    /*  Exact vertical center */
    display: none;
    align-items: center;
    justify-content: center;
}

/* Footer (Add Btn) */
.category-footer {
    border-top: 1px solid #f1f5f9;
}

.add-item-btn {
    width: 100%;
    padding: 10px;
    background: none;
    border: none;
    color: #718096;
    font-size: 0.85rem;
    cursor: pointer;
    text-align: left;
    padding-left: 15px;
    transition: color 0.2s;
}

.add-item-btn:hover {
    background: #f7fafc;
    color: var(--primary-color);
}

/* Edit Mode Visibility */
.hidden-unless-edit {
    display: none;
}

body.edit-mode .cat-actions,
body.edit-mode .item-actions,
body.edit-mode .hidden-unless-edit {
    display: flex !important;
}

/* New Category Card "Fake" */
.category-card.add-new-cat {
    border: 2px dashed #cbd5e0;
    background: rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    min-height: 80px;
    transition: all 0.2s;
}

.category-card.add-new-cat:hover {
    border-color: var(--primary-color);
    background: #fff;
    color: var(--primary-color);
}

.add-cat-content {
    font-weight: 600;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 8px;
}

body.edit-mode .category-body:empty {
    border: 2px dashed #cbd5e0;
    background: #f8fafc;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.edit-mode .item-actions button,
body.edit-mode .cat-actions button {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    /* Square and Centered */
    width: 24px;
    height: 24px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
}

body.edit-mode .item-actions button:hover,
body.edit-mode .cat-actions button:hover {
    background: #f0f0f0;
}

/* Specific Colors for clarity */
body.edit-mode .item-actions button .fa-trash,
body.edit-mode .cat-actions button .fa-trash {
    color: #dc2626;
    font-size: 0.85rem;
    /* Specific size */
}

body.edit-mode .item-actions button .fa-pen,
body.edit-mode .cat-actions button .fa-pen {
    color: #2563eb;
    font-size: 0.85rem;
    /* Specific size */
}

/* Empty Category visual cue in Edit Mode */
body.edit-mode .category-body:empty {
    border: 2px dashed #cbd5e0;
    background: #f8fafc;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.edit-mode .category-body:empty::after {
    content: 'Arraste textos para cá';
    color: #94a3b8;
    font-size: 0.85rem;
    font-style: italic;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.hidden {
    display: none !important;
}

.modal-card {
    background: #fff;
    width: 700px;
    max-width: 95%;
    max-height: 90vh;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
}

.mini-card {
    width: 400px;
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: #2d3748;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #a0aec0;
    cursor: pointer;
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
}

.input-full {
    width: 100%;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    box-sizing: border-box;
    /* Fix padding issue */
}

.input-full:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.2);
}

.modal-footer {
    padding: 20px 25px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: #f8fafc;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

.view-content-area {
    line-height: 1.6;
    color: #4a5568;
    white-space: pre-wrap;
    /* Preserve formatting */
}

/* Helpers */
.btn {
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #0069d9;
}

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.btn-secondary:hover {
    background: #cbd5e0;
}

.btn-save {
    background: #10b981;
    color: white;
}

.btn-cancel {
    background: #ef4444;
    color: white;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

/* Board Lanes Layout (Masonry: Flex Row of Columns) */
.board-lanes {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    justify-content: stretch;
    width: 100%;
}

.lane {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

/* Category Card */
.category-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
    transition: box-shadow 0.2s;
}

/* --- Styles for Surgical Descriptions Page (Smart Modal) --- */
.desc-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
}

.desc-modal {
    background: var(--card-bg);
    /* Use var from root */
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.desc-modal h2 {
    margin-top: 0;
    color: var(--primary-color);
    border-bottom: 2px solid #0a9396;
    /* accent color match */
    padding-bottom: 10px;
}

.desc-modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-sub);
}

.smart-form-group {
    margin-bottom: 15px;
}

.smart-form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.smart-input {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: #fafafa;
    color: var(--text-main);
}

.smart-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.smart-btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

.smart-btn-primary {
    background: linear-gradient(135deg, var(--primary-color), #0a9396);
    color: white;
}

.smart-btn-secondary {
    background: #fff;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

/* Custom Icon Sizing */
.cat-icon-custom {
    max-height: 40px;
    height: 40px;
    width: auto;
    margin-right: 8px;
    object-fit: contain;
    vertical-align: middle;
}

/* Icon Upload Preview */
.icon-preview {
    width: 40px;
    height: 40px;
    object-fit: contain;
    margin-left: 10px;
    vertical-align: middle;
    background: #fff;
    padding: 2px;
    border-radius: 4px;
}

/* Fix for SOAP Page Header Height */
#soap-page .category-header {
    min-height: 50px;
    padding: 5px 15px;
    align-items: center;
    box-sizing: border-box;
    display: flex;
}

/* Ensure SweetAlert is always on top of custom modals */
.swal2-container {
    z-index: 100000 !important;
}