/* ===== SAVE AS TEMPLATE DIALOG STYLES ===== */

.save-as-template-dialog {
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--panel-border);
    background: var(--panel-bg);
}

.dialog-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 18px;
}

.dialog-content {
    flex: 1;
    overflow: auto;
    padding: 24px;
}

.dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid var(--panel-border);
    background: var(--dashboard-bg);
}

/* ===== FORM STYLES ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--panel-border);
    border-radius: var(--border-radius);
    background: var(--panel-bg);
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-control:disabled {
    background: var(--dashboard-bg);
    color: var(--text-secondary);
    cursor: not-allowed;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

select.form-control {
    cursor: pointer;
}

.form-text {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.error-message {
    color: var(--accent-red);
    font-size: 12px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.error-message::before {
    content: "⚠";
    font-size: 10px;
}

/* ===== ICON PICKER ===== */
.save-as-template-dialog .icon-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: 8px;
    max-height: 220px;
    overflow: auto;
    padding-top: 8px;
}

.save-as-template-dialog .icon-choice {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.save-as-template-dialog .icon-choice i {
    font-size: 18px;
}

.save-as-template-dialog .icon-choice.selected,
.save-as-template-dialog .icon-choice:hover {
    outline: 2px solid var(--accent-blue);
}

/* ===== CHECKBOX STYLES ===== */
.save-as-template-dialog .checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 0;
}

.save-as-template-dialog .checkbox-label input[type="checkbox"] {
    display: none;
}

.save-as-template-dialog .checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid var(--panel-border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.save-as-template-dialog .checkbox-label:hover .checkmark {
    border-color: var(--accent-blue);
}

.save-as-template-dialog .checkbox-label input[type="checkbox"]:checked + .checkmark {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
}

.save-as-template-dialog .checkbox-label input[type="checkbox"]:checked + .checkmark::after {
    content: "✓";
    color: white;
    font-size: 12px;
    font-weight: bold;
}

/* ===== USER SELECTOR STYLES ===== */
.user-selector {
    position: relative;
}

.selected-users {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    margin-bottom: 8px;
}

.selected-user {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--accent-blue);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
}

.btn-remove {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    padding: 0;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.btn-remove:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    max-height: 200px;
    overflow: auto;
}

.search-result {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--panel-border);
}

.search-result:last-child {
    border-bottom: none;
}

.search-result:hover {
    background: var(--dashboard-bg);
}

.search-result i {
    color: var(--text-secondary);
    width: 16px;
}

.search-result span {
    color: var(--text-primary);
    font-weight: 500;
}

.search-result small {
    color: var(--text-secondary);
    font-size: 12px;
    margin-left: auto;
}

/* ===== VALIDATION STATES ===== */
.form-control.error {
    border-color: var(--accent-red);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-control.success {
    border-color: var(--accent-green);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* ===== LOADING STATES ===== */
.form-control.loading {
    position: relative;
}

.form-control.loading::after {
    content: "";
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid var(--panel-border);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: translateY(-50%) rotate(360deg);
    }
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .dialog-header,
    .dialog-content,
    .dialog-footer {
        padding-left: 16px;
        padding-right: 16px;
    }
    
    .dialog-footer {
        flex-direction: column-reverse;
    }
    
    .dialog-footer .btn {
        width: 100%;
        justify-content: center;
    }
    
    .selected-users {
        margin-bottom: 12px;
    }
    
    .search-results {
        position: fixed;
        left: 16px;
        right: 16px;
        top: auto;
        bottom: 16px;
        max-height: 300px;
    }
}

/* ===== ACCESSIBILITY ===== */
.form-control:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

.save-as-template-dialog .checkbox-label:focus-within .checkmark {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

.btn:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

/* ===== ANIMATIONS ===== */
.dialog-content {
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-results {
    animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.selected-user {
    animation: slideInUser 0.2s ease-out;
}

@keyframes slideInUser {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}