/* ============================================
   TEXT TOOL STYLES
   ============================================ */

/* Text Box Container */
.text-box {
    position: absolute;
    border: 2px solid transparent;
    background: transparent;
    cursor: default;
    min-width: 50px;
    min-height: 30px;
    box-sizing: border-box;
    z-index: 10;
    /* Prevent text selection when not editing */
    user-select: none;
    -webkit-user-select: none;
}

/* Text shadow element - sits behind text box */
.text-shadow-element {
    position: absolute;
    pointer-events: none;
    z-index: 5;
}

.text-box.selected {
    border: 2px dashed var(--accent);
    cursor: move;
    box-shadow: 0 0 0 1px rgba(74, 158, 255, 0.3);
}

.text-box.editing {
    border-style: solid;
    border-color: #4ade80;
    /* Allow text selection when editing */
    user-select: text;
    -webkit-user-select: text;
}

/* Text Box Content */
.text-box-content {
    width: 100%;
    height: 100%;
    outline: none;
    overflow: hidden;
    white-space: pre-wrap;
    word-wrap: break-word;
    cursor: text;
    padding: 4px;
    box-sizing: border-box;
    line-height: 1.2;
}

/* Allow text selection in content only when parent is editing */
.text-box.editing .text-box-content {
    user-select: text;
    -webkit-user-select: text;
}

/* Text Box Resize Handles - hidden by default */
.text-box-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ffffff;
    border: 1px solid var(--accent);
    border-radius: 2px;
    z-index: 10;
    display: none; /* Hidden by default */
}

/* Only show handles when text box is selected */
.text-box.selected .text-box-handle {
    display: block;
}

.text-box-handle.nw { top: -5px; left: -5px; cursor: nwse-resize; }
.text-box-handle.n { top: -5px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.text-box-handle.ne { top: -5px; right: -5px; cursor: nesw-resize; }
.text-box-handle.e { top: 50%; right: -5px; transform: translateY(-50%); cursor: ew-resize; }
.text-box-handle.se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.text-box-handle.s { bottom: -5px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.text-box-handle.sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.text-box-handle.w { top: 50%; left: -5px; transform: translateY(-50%); cursor: ew-resize; }

/* Text Options Bar Enhanced */
#textOptions {
    flex-wrap: wrap;
    gap: 8px;
}

#textOptions .option-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.font-search-container {
    position: relative;
    display: inline-block;
}

.font-search-input {
    width: 180px;
    background: var(--bg-medium);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 4px 24px 4px 8px;
    font-size: 11px;
    color: var(--text-primary);
    cursor: pointer;
}

.font-search-input:focus {
    outline: none;
    border-color: var(--accent);
}

.font-search-arrow {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-dim);
    font-size: 10px;
}

.font-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 300px;
    overflow-y: auto;
    background: var(--bg-medium);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 4px 4px;
    z-index: 1000;
    display: none;
}

.font-dropdown.active {
    display: block;
}

.font-dropdown-section {
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}

.font-dropdown-section:last-child {
    border-bottom: none;
}

.font-dropdown-label {
    padding: 4px 10px;
    font-size: 9px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg-dark);
}

.font-dropdown-item {
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.font-dropdown-item:hover {
    background: var(--accent);
    color: white;
}

.font-dropdown-item.preloaded {
    color: var(--text-primary);
}

.font-dropdown-item.preloaded::after {
    content: '✓';
    float: right;
    color: var(--accent);
    font-size: 10px;
}

/* Text Properties Modal */
.text-properties-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    z-index: 2000;
    min-width: 320px;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    display: none;
}

.text-properties-modal.active {
    display: block;
}

.text-properties-modal h3 {
    margin: 0 0 16px 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

.text-prop-row {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    gap: 8px;
}

.text-prop-row label {
    flex: 0 0 100px;
    font-size: 11px;
    color: var(--text-secondary);
}

.text-prop-row input[type="number"],
.text-prop-row input[type="text"],
.text-prop-row select {
    flex: 1;
    background: var(--bg-medium);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 6px 8px;
    font-size: 11px;
    color: var(--text-primary);
}

.text-prop-row input:focus,
.text-prop-row select:focus {
    outline: none;
    border-color: var(--accent);
}

.text-prop-group {
    display: flex;
    gap: 8px;
    flex: 1;
}

.text-prop-group input {
    flex: 1;
}

.text-style-buttons {
    display: flex;
    gap: 4px;
}

.text-style-btn {
    width: 28px;
    height: 28px;
    background: var(--bg-medium);
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

.text-style-btn:hover {
    background: var(--bg-light);
    color: var(--text-primary);
}

.text-style-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.text-align-buttons {
    display: flex;
    gap: 4px;
}

.text-align-btn {
    width: 28px;
    height: 28px;
    background: var(--bg-medium);
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

.text-align-btn:hover {
    background: var(--bg-light);
}

.text-align-btn.active {
    background: var(--accent);
    color: white;
}

.text-props-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

/* Color picker input styled */
.color-input-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.color-input-wrapper input[type="color"] {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 3px;
    cursor: pointer;
    padding: 0;
    background: transparent;
}

.color-input-wrapper input[type="text"] {
    flex: 1;
    text-transform: uppercase;
}

/* Text layer indicator in layers panel */
.layer-item.text-layer {
    position: relative;
}

.layer-text-icon {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: var(--accent);
    font-weight: 700;
    background: var(--bg-medium);
    padding: 2px 5px;
    border-radius: 3px;
    border: 1px solid var(--border);
}
